From c0de6063f61b9ff65019984ec4dffb2dac713b5e Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 3 May 2026 01:03:31 -0400 Subject: [PATCH] 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. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index bd0b5ce0932..3dc91e972e1 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "./package.json": "./package.json" }, + "sideEffects": false, "homepage": "https://emberjs.com/", "bugs": { "url": "https://github.com/emberjs/ember.js/issues"