RFC: Add stat reporting for tree-shaken modules
See original GitHub issueFeature request
If a module is tree-shaken, provide a stat entry field claiming which dependencies have been shaken.
What is the expected behavior?
When studying a module stat, offer the information if a dependency is shaken.
{
"name": "my-module.js",
"reasons": [{ filename: "/a/b/c.js", treeShaken: true }, /* ... */]
}
Or similar. This would imply that /a/b/c.js
imported my-module.js
, but it was shaken from c.js
. There are certainly other schemas that could be used instead.
What is motivation or use case for adding/changing the behavior?
I seek to:
- apply new
rules: [{ test: myTest, sideEffects: false }]
, but need to do an audit of the tree-shaken modules to know that turning on this rule is safe- by getting a list of shaken modules, I can do a manual study to assert that no reading/writing from the global scope occurs, and verify that my optimization is safe
- my project has thousands of modules, so studying each of them is challenging. I want
sideEffects: false
set for nearly all ESM modules in my codebase, but want to audit those that are pruned with precision (vs many thousands in play). Having reporting will help me see what webpack is optimizing out, and allow me to assert these optimizations are safe before checking in the optimization
How should this be implemented in your opinion?
I assume that webpack already identifies these modules during compilation. Allow for that state to be captured into the Stats
interface, so as to help provide diagnostics.
Are you willing to work on this yourself?
Possibly, if given low to mid level coaching on what modules are in play, what edge cases to look out for, etc.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top GitHub Comments
btw there is a plugin that marks modules with sideEffect flag https://github.com/vankop/side-effect-free-webpack-stat-plugin
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.