Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): correct wrap ES2022 classes with …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
alan-agius4 authored and clydin committed Mar 10, 2023
1 parent 2f36b53 commit a936805
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default function (): PluginObj {
if (
elementKey.isIdentifier() &&
(!elementValue.isExpression() ||
canWrapProperty(elementKey.get('name'), elementValue))
canWrapProperty(elementKey.node.name, elementValue))
) {
shouldWrap = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,9 @@ describe('adjust-static-class-members Babel plugin', () => {
class CommonModule {
static ɵfac = function CommonModule_Factory(t) { return new (t || CommonModule)(); };
static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: CommonModule });
static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({ providers: [
{ provide: NgLocalization, useClass: NgLocaleLocalization },
] });
static ɵinj = ɵngcc0.ɵɵdefineInjector({ providers: [
{ provide: NgLocalization, useClass: NgLocaleLocalization },
] });
}
`,
expected: `
Expand All @@ -797,7 +797,7 @@ describe('adjust-static-class-members Babel plugin', () => {
static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({
type: CommonModule,
});
static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({
static ɵinj = ɵngcc0.ɵɵdefineInjector({
providers: [
{
provide: NgLocalization,
Expand Down

0 comments on commit a936805

Please sign in to comment.