Skip to content

Commit 5b3c571

Browse files
NullVoxPopuliclaude
andcommitted
rollup: refactor pure-package check to a named list
Pull the package list out of the if-cascade into a `PURE_INTERNAL_PACKAGES` array so future additions are a one-line append. Empirically tried expanding to `@glimmer/util`, `@glimmer/wire-format`, `@glimmer/encoder`, `@glimmer/owner`, `@glimmer/reference`, `@glimmer/vm`, `@glimmer/destroyable`, `@glimmer/global-context`, `@glimmer/interfaces` — none of them moved the bundle in either hello-world or classic v2-app, so kept the original conservative set. No behavior change. Same hello-world (131.27 / 42.06) and classic (309.68 / 96.28). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 4b8a9e0 commit 5b3c571

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

rollup.config.mjs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,26 @@ function sharedESMConfig({ input, debugMacrosMode, includePackageMeta = false })
115115
}
116116

117117
// Tell rollup which source files actually have top-level side effects.
118-
// Anything not on this list is treated as side-effect-free, so unused
119-
// imports of it can be elided rather than carried into a downstream
120-
// shared chunk. By default rollup is conservative (`true`) — most
121-
// internal files don't have a `sideEffects: false` package.json visible
122-
// at the right boundary.
118+
// Anything matched by `pure` is treated as side-effect-free: unused
119+
// imports of it can be dropped rather than carried into a downstream
120+
// shared chunk. The packages here are either explicitly
121+
// `sideEffects: false` in their own package.json (which gets lost once
122+
// files are co-bundled into shared chunks across packages) or are pure
123+
// utility / data-shape packages with no top-level mutation.
123124
function moduleHasSideEffects(id) {
124-
// External (node_modules) — leave default behavior.
125125
if (!id.includes('/packages/')) return true;
126-
// Files under `@glimmer/debug` are pure debug helpers; the package
127-
// itself declares `sideEffects: false`, but that gets lost when files
128-
// are bundled into shared chunks across packages. Force-mark them as
129-
// pure here so unused imports are dropped at the chunk boundary.
130-
if (id.includes('/packages/@glimmer/debug/')) return false;
131-
if (id.includes('/packages/@glimmer/debug-util/')) return false;
132-
if (id.includes('/packages/@glimmer/local-debug-flags/')) return false;
133-
// Default: assume internal files may have side effects.
126+
for (const pkg of PURE_INTERNAL_PACKAGES) {
127+
if (id.includes(`/packages/${pkg}/`)) return false;
128+
}
134129
return true;
135130
}
136131

132+
const PURE_INTERNAL_PACKAGES = [
133+
'@glimmer/debug',
134+
'@glimmer/debug-util',
135+
'@glimmer/local-debug-flags',
136+
];
137+
137138
function glimmerSyntaxESM() {
138139
return {
139140
onLog: handleRollupWarnings,

0 commit comments

Comments
 (0)