New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generateBundle ChunkInfo modules does not contain treeshaken modules #3651
Comments
Yes, this is not a bug but is listed as a breaking change of version 2, see https://github.com/rollup/rollup/releases/tag/v2.0.0:
The reason is technical but the thing is, a tree-shaken module IS not part of any chunk, so it does not make sense to list it as part of any chunk. Unfortunately, the new chunking algorithm WILL not list it as part of any chunk, so this cannot easily be fixed. The best idea to mitigate certain use cases I had so far would be to allow for plugins to specify that a module should never be tree-shaken. Then this module would again end up in some chunk even if it is empty. This is not done yet, but out of curiosity, would this solve your use-case? |
Thanks for that context and the link @lukastaegert, I missed that part of the changelog :) Not including fully tree-shaken modules in the chunk by default makes sense. I think a mechanism to mark particular modules as never treeshakable would solve my use case. I tried changing the contents that the css files export to trigger a side effect, and thus stop treeshaking and my output included the previously removed content: const properties = JSON.stringify(postCssOutput.tokens, null, 2);
- return `export default ${properties};`;
+ return `console.log('');export default ${properties};`; In my original poking at this is issue while not fully groking the documentation I tried using returning an object from my transform hook that set |
You can use |
There will be a feature to address this in the next minor version: #3663 |
Expected Behavior
In the
generateBundle
hook you can do the following to get an array of all the modules used within all the bundles.In rollup v1 all modules ids are present in that array. I would expect the same for rollup v2
Actual Behavior
In rollup v2 modules that have been tree shaken away are not present in the above
bundleModuleIds
arrayThe text was updated successfully, but these errors were encountered: