Rollup Tree-Shaking and the sideEffects Field: An Architecture Note
How Rollup decides which modules to drop, why package.json sideEffects is a trust boundary, and the checks that catch a wrong declaration before users do.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
How Rollup decides which modules to drop, why package.json sideEffects is a trust boundary, and the checks that catch a wrong declaration before users do.
Goal Enable tree-shaking of namespace imports ( import * as ns from 'pkg' ) when a dependency declares "sideEffects": false in its package.json , so that unused bindings are eliminated from the bundle. Constraints and uncertainty Rollup 4.x currently treats namespace imports as opaque references that prevent elimination of any exported binding, even when the
Conflict between package-level and module-level side-effect signals Rollup 4.x treats "sideEffects": false in package.json as a strong signal to eliminate unused exports, yet individual modules may contain top-level statements (such as console.log or mutation of global state) that are not annotated with /* @__PURE__ */ . The bundler must decide whether to tr