fix(code-splitting): treat class definition-time global reads as order-sensitive#10322
Merged
Merged
Conversation
hyfdev
force-pushed
the
codex/strict-scc-final-topology-assert
branch
from
July 16, 2026 15:14
ede4fd5 to
bc71bc1
Compare
hyfdev
force-pushed
the
codex/strict-class-def-order-sensitivity
branch
from
July 16, 2026 15:14
4709a6b to
4f804f3
Compare
hyfdev
force-pushed
the
codex/strict-class-def-order-sensitivity
branch
from
July 20, 2026 12:45
4f804f3 to
ab7808a
Compare
hyfdev
changed the base branch from
codex/strict-scc-final-topology-assert
to
main
July 20, 2026 12:45
hyfdev
force-pushed
the
codex/strict-class-def-order-sensitivity
branch
from
July 20, 2026 13:55
ab7808a to
b8df48d
Compare
✅ Deploy Preview for rolldown-rs canceled.
|
hyfdev
force-pushed
the
codex/strict-class-def-order-sensitivity
branch
from
July 20, 2026 14:02
b8df48d to
3b7f8b7
Compare
hyfdev
marked this pull request as ready for review
July 20, 2026 14:11
Merging this PR will not alter performance
Comparing Footnotes
|
IWANABETHATGUY
approved these changes
Jul 20, 2026
Member
Author
Merge activity
|
…r-sensitive (#10322) ## Summary Fixes the class order-sensitivity gap found while reviewing #10104. A class can be side-effect-free for tree shaking while its definition still reads mutable global state from an extends expression, computed key, static initializer, or static block. Reordering that class across a module that patches the global can change behavior. When Oxc certifies the whole class as side-effect-free, Rolldown now runs an independent definition-time visitor that collects only GlobalVarAccess and PureAnnotation reasons. It never invokes or short-circuits on tree-shaking analysis. Therefore a PureCJS target write remains tree-shaking-only, while its RHS and later siblings are still visited. The visitor covers evaluated binding defaults, computed keys, assignment RHS, direct IIFEs, and nested classes. It skips deferred function and method bodies and instance initializers. The tree-shaking channel is structurally unchanged: the original whole-class Oxc boolean remains its only input, and the new visitor can only add order-sensitive reasons. ## Regression coverage - PureCJS-only and literal binding-default cases remain order-insensitive. - PureCJS followed by a global read or pure-annotated call is order-sensitive in either operand order. - Static-block binding defaults, computed member keys, assignment RHS, direct IIFEs, heritage expressions, and nested class-definition work are covered. - Deferred arrow/function bodies, method bodies, and instance initializers remain order-insensitive. ## Validation - cargo test -p rolldown --lib — 87 passed. - cargo test -p rolldown — 87 unit and 49 integration tests passed; the only failure was the existing missing local test262 submodule. - cargo clippy -p rolldown --lib --tests -- -D warnings — clean. - cargo fmt --all -- --check — clean. Follow-up to #10104; addresses Major 1 from #10104 (comment). Draft, rebased directly onto main.
graphite-app
Bot
force-pushed
the
codex/strict-class-def-order-sensitivity
branch
from
July 21, 2026 01:50
3b7f8b7 to
ff32edb
Compare
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the class order-sensitivity gap found while reviewing #10104. A class can be side-effect-free for tree shaking while its definition still reads mutable global state from an extends expression, computed key, static initializer, or static block. Reordering that class across a module that patches the global can change behavior.
When Oxc certifies the whole class as side-effect-free, Rolldown now runs an independent definition-time visitor that collects only GlobalVarAccess and PureAnnotation reasons. It never invokes or short-circuits on tree-shaking analysis. Therefore a PureCJS target write remains tree-shaking-only, while its RHS and later siblings are still visited.
The visitor covers evaluated binding defaults, computed keys, assignment RHS, direct IIFEs, and nested classes. It skips deferred function and method bodies and instance initializers.
The tree-shaking channel is structurally unchanged: the original whole-class Oxc boolean remains its only input, and the new visitor can only add order-sensitive reasons.
Regression coverage
Validation
Follow-up to #10104; addresses Major 1 from #10104 (comment).
Draft, rebased directly onto main.