Skip to content

revert "fix(@angular-devkit/build-optimizer): wrap classes which cont… #16690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,7 @@ function findStatements(

for (let index = statementIndex + 1; index < statements.length; ++index) {
const statement = statements[index];

if (!ts.isExpressionStatement(statement)) {
// The below is a workaround for NGCC as TS will never emit an EmptyStatement.
// See: https://github.com/angular/angular-cli/issues/16509#issuecomment-570198398
if (ts.isEmptyStatement(statement)) {
count++;
continue;
}

break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,6 @@ describe('wrap enums and classes transformer', () => {
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('should wrap classes which contain EmptyStatement', () => {
const input = tags.stripIndent`
let JigsawTrustedHtml = JigsawTrustedHtml_1 = class JigsawTrustedHtml {
constructor(_sanitizer, zone) {
}
static _getContext(magicNumber) {
return JigsawTrustedHtml_1._contexts[magicNumber];
}
};
JigsawTrustedHtml.ɵfac = function JigsawTrustedHtml_Factory(t) { };
// NGCC outputs an empty statement sometimes like the below:
// https://github.com/angular/angular-cli/issues/16509#issuecomment-570198398
JigsawTrustedHtml.ɵdir = ɵngcc0.ɵɵdefineDirective(); ;
JigsawTrustedHtml.ctorParameters = () => [
{ type: DomSanitizer },
{ type: NgZone }
];
`;

const output = tags.stripIndent`
let JigsawTrustedHtml = /*@__PURE__*/ (() => {
${input}

return JigsawTrustedHtml;
})();
`;

expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('should not wrap enum like which are inside of methods', () => {
const input = tags.stripIndent`
class LayoutDirective {
Expand Down