fix(webpack): downlevel NativeClass classes in files updated by earlier transformers - #11314
Merged
NathanWalker merged 1 commit intoJul 23, 2026
Merged
Conversation
…er transformers The NativeClass transformer's visitNode bailed out on any node flagged NodeFlags.Synthesized before checking for the SourceFile itself. A source file rebuilt by a preceding transformer (e.g. Angular's Ivy transform on files containing Angular-decorated classes) is itself flagged Synthesized, so the transformer skipped the entire file and @nativeclass decorators survived into the emitted bundle, crashing at runtime with 'ReferenceError: NativeClass is not defined'. Handle the SourceFile before the Synthesized bail-out; the per-statement Synthesized check in transformStatements still protects statements generated by earlier transformers and the transformer's own helper output.
|
View your CI Pipeline Execution ↗ for commit 95849d6
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
NathanWalker
approved these changes
Jul 23, 2026
NathanWalker
deleted the
fix/webpack-native-class-synthesized-source-file
branch
July 23, 2026 17:54
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.
PR Checklist
What is the current behavior?
In Angular projects, any file that contains both an Angular-decorated class (
@Injectable,@Directive,@Component, ...) and a@NativeClassclass is silently skipped by the NativeClass transformer. The@NativeClassdecorator survives into the emitted bundle as__decorate([NativeClass()], ...)and the app crashes at runtime with:Root cause: in the Angular webpack flavor the NativeClass transformer runs after Angular's Ivy transform. On files containing Angular-decorated classes, Ivy rebuilds the file via
factory.updateSourceFile(), so the resultingSourceFilenode itself carriests.NodeFlags.Synthesized. The transformer'svisitNodebails out on anySynthesizednode before reaching itsisSourceFilebranch, so the whole file is returned untouched. Files without Angular decorators pass through Ivy unchanged (originalSourceFile, no flag), which is why only this mixed-content case breaks.What is the new behavior?
visitNodehandles theSourceFilebefore theSynthesizedbail-out, so files rebuilt by earlier transformers are still processed. The per-statementSynthesizedcheck intransformStatementscontinues to protect statements generated by earlier transformers (e.g. Ivy's added imports and rewritten Angular classes) as well as the transformer's own helper output.Includes a regression test that runs the transformer after a preceding transformer which rebuilds the source file (simulating Ivy) — it fails without the fix and passes with it.