Skip to content

Commit ccbac7c

Browse files
Alanalexeagle
Alan
authored andcommitted
fix(@angular-devkit/build-optimizer): don't add pure comments in call expressions
When we removed tsickle from the library compilation pipeline the emitted JS changes for Classes. With tsc a class can be of kind CallExpression because of this syntax ``` let Foo = class Foo { constructor() { this.isExpandedChange = new EventEmitter(); } set isExpanded(value) { this.isExpandedChange.emit(value); } }; ``` In such case we shall not add `/*@__PURE__*/` inside this class Fixes #14084
1 parent 475ba66 commit ccbac7c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/angular_devkit/build_optimizer/src/transforms/prefix-functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function findTopLevelFunctions(parentNode: ts.Node): Set<ts.Node> {
4747
if (ts.isFunctionDeclaration(node)
4848
|| ts.isFunctionExpression(node)
4949
|| ts.isClassDeclaration(node)
50+
|| ts.isClassExpression(node)
5051
|| ts.isArrowFunction(node)
5152
|| ts.isMethodDeclaration(node)
5253
) {

packages/angular_devkit/build_optimizer/src/transforms/prefix-functions_spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,23 @@ describe('prefix-functions', () => {
167167

168168
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
169169
});
170+
171+
it('doesn\'t add comment when inside class expression', () => {
172+
const input = tags.stripIndent`
173+
let Foo = class Foo {
174+
constructor() {
175+
this.isExpandedChange = new EventEmitter();
176+
}
177+
178+
set isExpanded(value) {
179+
this.isExpandedChange.emit(value);
180+
}
181+
};
182+
`;
183+
const output = tags.stripIndent`
184+
${input}
185+
`;
186+
187+
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
188+
});
170189
});

0 commit comments

Comments
 (0)