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
I want to bundle multiple separate outputs but share some chunks across these outputs. I'm using Vite with a main application and multiple web workers being generated. But its the same when using Rollup directly with multiple inputs/outputs.
Every workers pull some functions from the shared library. Imagine a dependency chart like this:
My goal is to share the chunk between the main and worker outputs as the shared codebase can be quite heavy. To do so I defined a manualChunks for the shared file on all compilations.
But I end up with different chunks duplicating my code:
When I additionally set { moduleSideEffects: "no-treeshake" } via a custom plugin I end up with different chunks.
When I disable tree shaking fully via treeshake: false I still end up with different chunks.
The mylib-shared chunk has different exports for each compilation depending on what is imported. Hence sharing of the chunk across compilations is not possible resulting in duplicate code shipped.
Feature Proposal
Similar to the mechanisms of disabling tree shaking, there should be a way to force an export of all symbols from a chunk.
This flagging should be possible either via "moduleSideEffects" on plugins or configs:
In both outputs the mylib-shared chunk would contain the same content, with all exports from mylib.shared.mjs and produce the same hash. This way it can be shared between main.js and worker.js.
In a perfect version this "full-exports" would only prevent any tree-shaking and export removal of the specific module. e.g. any unused functions of a 3rd party lib is still removed, only the symbols of mylib remain.
The text was updated successfully, but these errors were encountered:
Feature Use Case
I want to bundle multiple separate outputs but share some chunks across these outputs. I'm using Vite with a main application and multiple web workers being generated. But its the same when using Rollup directly with multiple inputs/outputs.
Every workers pull some functions from the shared library. Imagine a dependency chart like this:
My goal is to share the chunk between the main and worker outputs as the shared codebase can be quite heavy. To do so I defined a manualChunks for the shared file on all compilations.
But I end up with different chunks duplicating my code:
{ moduleSideEffects: "no-treeshake" }
via a custom plugin I end up with different chunks.treeshake: false
I still end up with different chunks.The mylib-shared chunk has different exports for each compilation depending on what is imported. Hence sharing of the chunk across compilations is not possible resulting in duplicate code shipped.
Feature Proposal
Similar to the mechanisms of disabling tree shaking, there should be a way to force an export of all symbols from a chunk.
This flagging should be possible either via "moduleSideEffects" on plugins or configs:
config:
plugin:
In both outputs the mylib-shared chunk would contain the same content, with all exports from mylib.shared.mjs and produce the same hash. This way it can be shared between
main.js
andworker.js
.In a perfect version this "full-exports" would only prevent any tree-shaking and export removal of the specific module. e.g. any unused functions of a 3rd party lib is still removed, only the symbols of mylib remain.
The text was updated successfully, but these errors were encountered: