Skip to content

Commit e135d7f

Browse files
filipesilvahansl
authored andcommitted
fix(@angular-devkit/build-optimizer): don't exceed call stack with big files
Related to microsoft/TypeScript#17033 Fix #9636
1 parent 9114664 commit e135d7f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/angular_devkit/build_optimizer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"loader-utils": "^1.1.0",
1616
"source-map": "^0.5.6",
17-
"typescript": "~2.7.2",
17+
"typescript": "~2.9.1",
1818
"webpack-sources": "^1.1.0"
1919
}
2020
}

packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts

+27
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// tslint:disable-next-line:no-implicit-dependencies
99
import { tags } from '@angular-devkit/core';
1010
import { RawSourceMap } from 'source-map';
11+
import { TransformJavascriptOutput } from '../helpers/transform-javascript';
1112
import { buildOptimizer } from './build-optimizer';
1213

1314

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

146147
expect(() => buildOptimizer({ content: input, strict: true })).toThrow();
147148
});
149+
150+
// TODO: re-enable this test when updating to TypeScript >2.9.1.
151+
// The `prefix-classes` tests will also need to be adjusted.
152+
// See https://github.com/angular/devkit/pull/998#issuecomment-393867606 for more info.
153+
xit(`doesn't exceed call stack size when type checking very big classes`, () => {
154+
// BigClass with a thousand methods.
155+
// Clazz is included with ctorParameters to trigger transforms with type checking.
156+
const input = `
157+
var BigClass = /** @class */ (function () {
158+
function BigClass() {
159+
}
160+
${Array.from(new Array(1000)).map((_v, i) =>
161+
`BigClass.prototype.method${i} = function () { return this.myVar; };`,
162+
).join('\n')}
163+
return BigClass;
164+
}());
165+
${clazz}
166+
Clazz.ctorParameters = function () { return []; };
167+
`;
168+
169+
let boOutput: TransformJavascriptOutput;
170+
expect(() => {
171+
boOutput = buildOptimizer({ content: input });
172+
expect(boOutput.emitSkipped).toEqual(false);
173+
}).not.toThrow();
174+
});
148175
});
149176

150177
describe('whitelisted modules', () => {

0 commit comments

Comments
 (0)