fix(angular-rspack): keep class field closures per instance in minified builds - #37066
Open
leosvelperez wants to merge 2 commits into
Open
leosvelperez wants to merge 2 commits into
leosvelperez wants to merge 2 commits into
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit a157506
☁️ Nx Cloud last updated this comment at |
Contributor
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
…ed builds Production builds miscompiled class field initializers that pass a callback to a helper, such as `injectVirtualizer(() => ...)` from @tanstack/angular-virtual. The SWC minifier inlined the helper and hoisted the callback into a variable shared by the enclosing scope, so every instance read the callback of the last one constructed. Set `inline: 0` and `reduce_funcs: false` in the SWC compress options for browser and server builds. Either flag alone still miscompiles.
Production builds miscompiled class field initializers that pass a callback to a helper when the class came from a dependency that ships native class fields. The SWC minifier hoisted the callback into a variable shared by the enclosing scope, so every instance read the callback of the last one constructed. App code was not affected because the swc-loader rule compiles it to ES5 first. Set the same `inline: 0` and `reduce_funcs: false` compress options on the production minimizer.
leosvelperez
force-pushed
the
gh-37050
branch
from
September 16, 2026 08:15
e6c9ec2 to
a157506
Compare
leosvelperez
marked this pull request as ready for review
September 16, 2026 11:17
4 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.
Current Behavior
Production builds from
@nx/angular-rspackand@nx/rspackcan break classes whose field initializers pass a callback to a helper. Every instance ends up calling the callback of the last instance created.The SWC minifier inlines the helper and assigns the callback to a variable that all instances share. In Angular apps this breaks
injectVirtualizerfrom@tanstack/angular-virtualwhen a page has more than one virtual list. In@nx/rspackapps, the default swc-loader rule compiles app code down to ES5, so there the bug hits dependencies that ship native class fields.Expected Behavior
Each instance keeps its own callback in minified production builds, for browser and server builds.
Related Issue(s)
Fixes #37050
Implementation Notes
compress: { inline: 0, reduce_funcs: false }. Either flag alone still miscompiles. Rspack keeps addingpasses: 2to the object.compress: falsegrows raw output 167% to 176%, andconcatenateModules: falsemisses helpers in the same file. Swappingreduce_funcs: falseforreduce_vars: falseworks but adds 1.8% gzip.@swc/core1.16.2 and the latest nightly. The options can go once an rspack release ships the fix.@nx/rspackprojects whosecomposePluginsconfig replacesoptimization.minimizer, such as the generated Nest config.View Polygraph session ↗