Rollup ESM bundle retains unused exports despite tree-shaking
0 reputation · 29 Nov 2020, 06:22 UTC
This build configures Rollup to tree-shake an ES-module bundle for a low-traffic site. The goal is to confirm that unused exports are removed based on side-effect analysis, and to understand whether retained code is expected behavior or a configuration gap.
Rollup documentation indicates tree-shaking depends on accurate side-effect detection for imported files, and behavior may differ between Rollup 3.x and 4.x because of changes to side-effect flag handling. It is unclear whether a specific import is being treated as side-effectful, preventing elimination of an unused export.
Plugin ordering, particularly minification plugins, could preserve dead code before the bundle is finalized.
Which Rollup version governs side-effect flag handling in this build? Is an imported module being treated as side-effectful, and what evidence appears in the bundle output? Does minifier placement change whether unused exports survive tree-shaking?