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
We've introduced EsmLibraryPlugin to make library output more clean and analyzable. But it's still experimental, here are some limits for now:
Runtime
Runtime code is still not good enough, we should avoid using the __webpack_require__ as the whole runtime namespace, every runtime method assigns itself to the __webpack_require__ object. This makes it hard for bundler to analyse useless runtime code and remove them.
Ideally, we should refactored each of them into pure util functions, and exports them.
Split chunks causing cycles
Well, yes, SplitChunks can work as expected for output code, but not as expected for running. SplitChunks for ESM output may not work as your expectation.
For example, imagine there is a module graph looks like this: A imports B imports C. We know if we do not split any module, there would be only 1 single chunk contains A, B and C. But if we split B into another chunk, if Rspack do nothing extra, the output are 2 chunks, the first chunk contains A and C, the second chunk contains B. A depends on B, so first chunk depends on second chunk, B depends on C, so second chunk depends on first chunk, there comes a cycle.
Possible solution
When we split a module, we either split the dependencies with it, or split its dependencies into another chunk. All we do is to make its dependencies away from the original chunk, so we can avoid the cycle.
But how we achieve it ? Modify the SplitChunksPlugin or we can make an easy one for library users ?
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.
-
We've introduced EsmLibraryPlugin to make library output more clean and analyzable. But it's still experimental, here are some limits for now:
Runtime
Runtime code is still not good enough, we should avoid using the
__webpack_require__as the whole runtime namespace, every runtime method assigns itself to the__webpack_require__object. This makes it hard for bundler to analyse useless runtime code and remove them.Possible solution
Ideally, we should refactored each of them into pure util functions, and exports them.
Split chunks causing cycles
Well, yes,
SplitChunkscan work as expected for output code, but not as expected for running. SplitChunks for ESM output may not work as your expectation.For example, imagine there is a module graph looks like this: A imports B imports C. We know if we do not split any module, there would be only 1 single chunk contains A, B and C. But if we split B into another chunk, if Rspack do nothing extra, the output are 2 chunks, the first chunk contains A and C, the second chunk contains B. A depends on B, so first chunk depends on second chunk, B depends on C, so second chunk depends on first chunk, there comes a cycle.
Possible solution
When we split a module, we either split the dependencies with it, or split its dependencies into another chunk. All we do is to make its dependencies away from the original chunk, so we can avoid the cycle.
But how we achieve it ? Modify the
SplitChunksPluginor we can make an easy one for library users ?Beta Was this translation helpful? Give feedback.
All reactions