Commit 4b8a9e0
rollup: mark @glimmer/debug{,-util,-flags} as side-effect-free in treeshake
Each of these packages already declares \`sideEffects: false\` in its
own \`package.json\`, but that declaration is lost the moment rollup
bundles their source files into shared chunks alongside other-package
runtime code. Once that happens, downstream bundlers (vite/rolldown
consuming ember-source's dist/prod) load the chunk for any runtime
symbol from another package and end up evaluating the debug top-level
(e.g. the \`STYLES\` const, \`LogFragmentBuffer\` class definitions,
ANNOTATION_STYLES array) — even though every actual call site is
behind \`if (LOCAL_DEBUG) {…}\` and gets DCE'd by Babel.
Add a \`treeshake.moduleSideEffects\` callback to the shared ESM
rollup config that explicitly marks files under those three packages
as pure. Anything else stays default (conservative).
Result: the \`render/styles.ts\` / \`render/buffer.ts\` /
\`render/fragment.ts\` content stops getting bundled into shared chunks
like \`curried-*.js\` at the dist-build stage. Downstream bundlers see
the chunks without any debug top-level code at all.
| | hello-world raw | hello-world gzip | classic v2-app raw | classic v2-app gzip |
| - | - | - | - | - |
| before | 133.40 KB | 42.66 KB | 317.74 KB | 98.77 KB |
| after | 131.27 KB | 42.06 KB | 309.68 KB | 96.28 KB |
Verified: \`pnpm lint\`, \`pnpm type-check:internals\`, both
v1/v2-app-template smoke-test \`pnpm test\` pass 1/1, hello-world
shrinks across the board.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent e763868 commit 4b8a9e0
1 file changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
| |||
0 commit comments