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
It's actually a question when I use Vite but I'm not sure which side is more appropriate to discuss this so I'd like to copy the question to both sides if you folks don't mind.
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hi rollup team,
It's actually a question when I use Vite but I'm not sure which side is more appropriate to discuss this so I'd like to copy the question to both sides if you folks don't mind.
vitejs/vite#18815
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 theexternalconfig 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 frompeerslayer doesn't work as expected.Reproduction:
https://github.com/Jinjiang/reproductions/tree/debug-bit-peer-deps-20241127
The key config:
and the source code for peers bundle:
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-domwork as expected but@emotion/styleddoesn'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