Using fluent-theme will throw errors on using something like nextJS. I know I can import from lib-commonjs, but even those commonjs packages will import stuff like office-ui-fabric-react/lib/Styling
which in turn uses es modules (instead of referencing office-ui-fabric-react/lib-commonjs/Styling
).
There is more problems like document undefined
due to @microsoft/load-themed-styles/lib/index
registerStyles
not checking if document is defined.
I could go and create the stack traces and detailed error messages, but I guess that the new fluent-theme is still in preview and this has not yet been optimized.
CC'ing @Vitalius1 as he may have more context given that he is one of the people working on integrating fluent theming.
I am guessing @kenotron or @cliffkoh could be more helpful here as this is more related to imports (not my area of expertise 🙄)
@khmakoto please sync with @kenotron or myself offline to discuss a fix for this.
Sorry @Vitalius1, I'll sync with @cliffkoh of @kenotron to discuss this. Thanks.
Two issues here:
Also, check out the apps/ssr-tests to see how that works
esm
: https://www.npmjs.com/package/esm@kenotron I don't think this is a bug here in paths.
Referencing package based imports in the prod code creates massive bloat for AMD bundling partners or any partner using Webpack < 4. In small packages where we know the entire package will be used, this is not a big deal, but for large packages like office-ui-fabric-react
, non Webpack-4 bundlers end up pulling everything in.
Instead of changing the path based imports, can partners in this scenario simply map the /lib/ folders to /lib-commonjs/ if they need to resolve commonjs paths? This is what we do for unit tests which still require commonjs.
I still think there MAYBE be a bug depending on where the imports are.
Looking @khmakoto 's massive conversion PR (#7390), we are mostly dealing with experimental packages and app packages. Scoping wise, this issue is with fluent-theme imports of office-ui-fabric-react/lib/Styling
. We should focus on that package in the PR probably.
As @dzearing said, if the imported target is large like OUFR itself, we shouldn't import that whole package. I agree with this. However, /lib/Styling from OUFR is a direct forward of @uifabric/styling. In that case, I would have expected the replacement here in Mak’s PR to be:
import {Foo, Bar} from ‘@uifabric/styling’;
Rather than
import {Foo, Bar} from ‘office-ui-fabric-react’;
:tada:This issue was addressed in #7390, which has now been successfully released as @uifabric/[email protected]
.:tada:
Handy links: