Skip to content

Commit b5304e9

Browse files
NullVoxPopuliclaude
andcommitted
Drop dead PURE_INTERNAL_PACKAGES entries
Of the three entries previously in PURE_INTERNAL_PACKAGES, only `@glimmer/debug` actually contributes to the hello-world bundle size: | array contents | hello-world raw | gzip | | - | - | - | | `[]` (no callback) | 181.12 KB | 57.82 KB | | `['@glimmer/debug-util']` | 181.12 KB | 57.82 KB | | `['@glimmer/local-debug-flags']` | 181.12 KB | 57.82 KB | | `['@glimmer/debug']` | 172.99 KB | 55.35 KB | | all three | 172.99 KB | 55.31 KB | `@glimmer/debug-util` and `@glimmer/local-debug-flags` are already inferred pure by rolldown's static analysis (their content either has no top-level statements that look like side effects, or gets fully stripped by the LOCAL_DEBUG macro in prod builds). Re-asserting them adds nothing. Inlined the array since the callback now checks a single path prefix. Added a note explaining the measurement so the next person adding to the list does so with data, not pattern-matching. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c0333cb commit b5304e9

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

rollup.config.mjs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,18 @@ function sharedESMConfig({ input, debugMacrosMode, includePackageMeta = false })
114114
};
115115
}
116116

117-
// Tell rollup which source files actually have top-level side effects.
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.
117+
// `@glimmer/debug` declares `sideEffects: false` in its own package.json,
118+
// but rolldown loses that signal when files from it get co-bundled into
119+
// shared chunks alongside non-pure code. Re-asserting purity at the
120+
// chunk-level callback recovers ~8 KB raw on the hello-world bundle by
121+
// letting unused imports of `@glimmer/debug` content drop out of those
122+
// chunks. Add other packages here only after measuring an actual
123+
// reduction.
124124
function moduleHasSideEffects(id) {
125-
if (!id.includes('/packages/')) return true;
126-
for (const pkg of PURE_INTERNAL_PACKAGES) {
127-
if (id.includes(`/packages/${pkg}/`)) return false;
128-
}
125+
if (id.includes('/packages/@glimmer/debug/')) return false;
129126
return true;
130127
}
131128

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

0 commit comments

Comments
 (0)