You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background:
In our business, we have a "peers" layer bundling core packages and attaching them onto globalThis. And then for upper-level apps we consume them through globalThis. To achieve this, we use the external config when bundling the upper-level apps.
Originally, we used webpack and it was fine. Then after migrating to Vite. we've found for some packages like @emotion/styled, the things we get from peers layer doesn't work as expected.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Background:
In our business, we have a "peers" layer bundling core packages and attaching them onto
globalThis
. And then for upper-level apps we consume them throughglobalThis
. To achieve this, we use theexternal
config when bundling the upper-level apps.Originally, we used webpack and it was fine. Then after migrating to Vite. we've found for some packages like
@emotion/styled
, the things we get frompeers
layer doesn't work as expected.Reproduction:
https://github.com/Jinjiang/reproductions/tree/debug-bit-peer-deps-20241127
After comparing the app bundles by webpack and Vite, I've found in the webpack-ed bundle there is a wrapper function:
for every package the app imports as external one, it will be wrapped by this function before further consumption like:
while in the Vite-ed bundle it doesn't have this which caused the inconsistent and incompatible behavior.
And it's not for every package. e.g.
react
,react-dom
work as expected but@emotion/styled
doesn'tIs there anyway we can make it works and match the behavior that webpack provides?
Thanks. 🙏
Beta Was this translation helpful? Give feedback.
All reactions