Commit c0de606
committed
Shrink hello-world bundle from 251 KB to 173 KB (-31%) via bundler hints
Two purely-additive bundler hints that let consumer bundlers
(vite/rolldown, webpack, esbuild) tree-shake aggressively through
ember-source's internal barrel re-exports without requiring any
source-file restructuring.
1. **`"sideEffects": false` on `ember-source/package.json`** -
declares that no module in this package has top-level side
effects that need to be preserved if the module's exports
are unused. The bundler can then DCE re-exports through
`index.ts` barrels that currently anchor the rest of the
graph in place.
This is safe in practice because rollup's chunking groups
symbols with their side effects: any chunk containing the
classic `Component` class also contains the
`setInternalComponentManager(CURLY_COMPONENT_MANAGER, Component)`
call, the `setHelperManager` registrations live in the chunk
that holds `helper.ts`, etc. Importing a symbol from a chunk
pulls the chunk's side effects along; apps that don't reach
those symbols don't need their side effects either.
2. **`treeshake.moduleSideEffects` callback in `rollup.config.mjs`** -
the package-level `sideEffects: false` declarations on
`@glimmer/debug`, `@glimmer/debug-util`, and
`@glimmer/local-debug-flags` get lost when rolldown emits
shared chunks (debug code from these packages can leak into
chunks that the renderer-only path then pulls in). The callback
re-asserts module purity at the chunk level so leaked debug
code drops out of the renderer-only path.
Measured against `smoke-tests/v2-app-hello-world-template`:
| | raw | gzip |
| - | - | - |
| before | 251.05 KB | 79.75 KB |
| after | 172.99 KB | 55.31 KB |
Classic `v2-app-template` and v1 `app-template` smoke tests still
build and pass. `pnpm test:node` 20/20. `pnpm vite build --mode
development` (full dev test suite app) builds clean.1 parent 673ba44 commit c0de606
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
0 commit comments