Repository navigation
Conversation
Member
|
I don't know if it's still the case, but I think the CLI had a transformer specifically to tree shake the old shape. We might have to double check that it won't break. |
mattrbeck
force-pushed
the
fix/ngtsc-set-class-metadata-static-block
branch
from
November 20, 2026 11:59
ba52915 to
7167b0d
Compare
mattrbeck
force-pushed
the
fix/ngtsc-set-class-metadata-static-block
branch
from
November 20, 2026 16:58
7167b0d to
ddb5d5c
Compare
Update IvyTransformationVisitor to unwrap ɵsetClassMetadata and ɵsetClassMetadataAsync IIFEs into a class static block whenever the class has no surviving non-Angular class or constructor-parameter decorators. Align ng-analyze via has_non_angular_ctor_param_decorators so ngp also emits ɵsetClassMetadata outside the class when custom constructor-parameter decorators wrap the class, and remove the complianceMode special case for ɵsetClassMetadata in ngp.
mattrbeck
force-pushed
the
fix/ngtsc-set-class-metadata-static-block
branch
from
November 20, 2026 17:06
ddb5d5c to
809da3c
Compare
Temporarily patch @angular/build oxc-transform (matching upstream PR angular/angular-cli#34770) so Angular class metadata inside ES2022 static blocks (including ngDevMode-guarded internal setClassMetadata calls in @angular/core FESM bundles) is elided and pure static Angular classes continue to be wrapped for tree-shaking.
Update full and local compliance .js goldens for static-block ɵsetClassMetadata emission in ngtsc, and normalize linked partial declarations in expectEmit since partial compilation preserves top-level ɵɵngDeclareClassMetadata.
mattrbeck
force-pushed
the
fix/ngtsc-set-class-metadata-static-block
branch
from
November 20, 2026 17:18
809da3c to
418a90a
Compare
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.
Alternative to #72101: instead of moving
ɵsetClassMetadata/ɵsetClassMetadataAsyncout ofstatic {}inngpwhenever a class has surviving member or method-parameter decorators, this PR updatesngtscto emitɵsetClassMetadata/ɵsetClassMetadataAsyncinside astatic { ... }block on the class whenever the class is not wrapped byCls = __decorate(..., Cls)(i.e. when there are no surviving non-Angular class or constructor-parameter decorators).When surviving non-Angular class or constructor-parameter decorators are present, both
ngtscandngpemitɵsetClassMetadataas a trailing IIFE after__decorate(ng-analyzeaddshas_non_angular_ctor_param_decoratorssongpmatchesngtscfor constructor-parameter decorators). Becausengtscandngpnow agree onstatic {}placement, this also removes thectx.complianceModespecial case forɵsetClassMetadatainngp.Split into 3 commits for reviewability:
ngtsc&ngpimplementation + unit specs (transform.ts,processor.ts,ng-analyze,ngtsc_spec.ts)@angular/buildoxc-transformstatic-block metadata elision (temporarypnpmpatch corresponding to upstream PR fix(@angular/build): elide Angular class metadata in static blocks in oxc-transform angular-cli#34770 so full-mode@angular/coreclasses withstatic {}metadata continue to be pure-wrapped and tree-shaken).jsgolden updates (expect_emit.ts+ 591 compliance goldens)Minimal failure example
Before (
mainngtsc):After (
ngtsc&ngp):Reservations (vs. #72101)
@angular/build(oxc-transform) update first (fix(@angular/build): elide Angular class metadata in static blocks in oxc-transform angular-cli#34770): Commit 2 temporarily patches@angular/buildviapatchedDependenciessooxc-transformremovesngDevMode/ngJitMode-guarded(ɵ)setClassMetadata*StaticBlocks and wraps pure static Angular classes in@angular/core/fesm2022/core.mjs(//packages/core/test/bundling/*andintegration/standalone-bootstrap); before landing, fix(@angular/build): elide Angular class metadata in static blocks in oxc-transform angular-cli#34770 should release and roll in normally (whichngpalso needs beforepackages/coreswitches tongp).ngtscmodifies 591 compliance.jsgoldens (and shifts ES5 downleveledɵsetClassMetadatainside the ES5 class closure right beforereturn Cls;). Partial compilation (GOLDEN_PARTIAL.js) keepsɵɵngDeclareClassMetadataas a top-level statement after the class to preserve the v12.0.0 partial-declaration format, so linked output still emits a trailing IIFE (normalized inexpect_emit.tsviarelocateStaticClassMetadataForLinked).__decorate: In dev /TestBed(ngDevMode = true),ɵsetClassMetadatainsidestatic {}now executes beforetslib.__decorateruns on prototype or static members. If an Angular decorator expression re-emitted inɵsetClassMetadataeagerly calls a@Decorated() staticmethod on the same class, or if a custom member decorator writes directly totarget.constructor.propDecorators,ɵsetClassMetadataruns before that decorator rather than after it.__decoratestill emit outsidestatic {}: While this eliminates the ~600-lineOutsideMetadataScope@ts-ignorevisibility-tracking machinery needed by fix(compiler-cli): emit ɵsetClassMetadata outside classes with member decorators #72101 for member and method-parameter decorators, classes with surviving custom class or constructor-parameter decorators still emitɵsetClassMetadataoutside the class afterCls = __decorate([...], Cls).