Skip to content

Commit a936805

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular-devkit/build-angular): correct wrap ES2022 classes with static properties
Prior to this commit, we only wrapped classes with static properties that were marked with `/*@__PURE__*/` comment due to a bug in the `adjust-static-class-members` Babel plugin were we did not call the `Identifier` name text to the `canWrapProperty` function. (cherry picked from commit 4d82e0d)
1 parent 2f36b53 commit a936805

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/angular_devkit/build_angular/src/babel/plugins/adjust-static-class-members.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export default function (): PluginObj {
271271
if (
272272
elementKey.isIdentifier() &&
273273
(!elementValue.isExpression() ||
274-
canWrapProperty(elementKey.get('name'), elementValue))
274+
canWrapProperty(elementKey.node.name, elementValue))
275275
) {
276276
shouldWrap = true;
277277
} else {

packages/angular_devkit/build_angular/src/babel/plugins/adjust-static-class-members_spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,9 @@ describe('adjust-static-class-members Babel plugin', () => {
783783
class CommonModule {
784784
static ɵfac = function CommonModule_Factory(t) { return new (t || CommonModule)(); };
785785
static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: CommonModule });
786-
static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({ providers: [
787-
{ provide: NgLocalization, useClass: NgLocaleLocalization },
788-
] });
786+
static ɵinj = ɵngcc0.ɵɵdefineInjector({ providers: [
787+
{ provide: NgLocalization, useClass: NgLocaleLocalization },
788+
] });
789789
}
790790
`,
791791
expected: `
@@ -797,7 +797,7 @@ describe('adjust-static-class-members Babel plugin', () => {
797797
static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({
798798
type: CommonModule,
799799
});
800-
static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({
800+
static ɵinj = ɵngcc0.ɵɵdefineInjector({
801801
providers: [
802802
{
803803
provide: NgLocalization,

0 commit comments

Comments
 (0)