Skip to content

Commit

Permalink
fix(@angular-devkit/build-optimizer): don't exceed call stack with bi…
Browse files Browse the repository at this point in the history
…g files

Related to microsoft/TypeScript#17033
Fix #9636
  • Loading branch information
filipesilva authored and hansl committed Jun 6, 2018
1 parent 5790eba commit ff8d654
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_optimizer/package.json
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"loader-utils": "^1.1.0",
"source-map": "^0.5.6",
"typescript": "~2.7.2",
"typescript": "~2.9.1",
"webpack-sources": "^1.1.0"
}
}
Expand Up @@ -8,6 +8,7 @@
// tslint:disable-next-line:no-implicit-dependencies
import { tags } from '@angular-devkit/core';
import { RawSourceMap } from 'source-map';
import { TransformJavascriptOutput } from '../helpers/transform-javascript';
import { buildOptimizer } from './build-optimizer';


Expand Down Expand Up @@ -145,6 +146,32 @@ describe('build-optimizer', () => {

expect(() => buildOptimizer({ content: input, strict: true })).toThrow();
});

// TODO: re-enable this test when updating to TypeScript >2.9.1.
// The `prefix-classes` tests will also need to be adjusted.
// See https://github.com/angular/devkit/pull/998#issuecomment-393867606 for more info.
xit(`doesn't exceed call stack size when type checking very big classes`, () => {
// BigClass with a thousand methods.
// Clazz is included with ctorParameters to trigger transforms with type checking.
const input = `
var BigClass = /** @class */ (function () {
function BigClass() {
}
${Array.from(new Array(1000)).map((_v, i) =>
`BigClass.prototype.method${i} = function () { return this.myVar; };`,
).join('\n')}
return BigClass;
}());
${clazz}
Clazz.ctorParameters = function () { return []; };
`;

let boOutput: TransformJavascriptOutput;
expect(() => {
boOutput = buildOptimizer({ content: input });
expect(boOutput.emitSkipped).toEqual(false);
}).not.toThrow();
});
});

describe('whitelisted modules', () => {
Expand Down

0 comments on commit ff8d654

Please sign in to comment.