Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 31c3fb7

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

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

@@ -127,6 +128,32 @@ describe('build-optimizer', () => {
127128

128129
expect(() => buildOptimizer({ content: input, strict: true })).toThrow();
129130
});
131+
132+
// TODO: re-enable this test when updating to TypeScript >2.9.1.
133+
// The `prefix-classes` tests will also need to be adjusted.
134+
// See https://github.com/angular/devkit/pull/998#issuecomment-393867606 for more info.
135+
xit(`doesn't exceed call stack size when type checking very big classes`, () => {
136+
// BigClass with a thousand methods.
137+
// Clazz is included with ctorParameters to trigger transforms with type checking.
138+
const input = `
139+
var BigClass = /** @class */ (function () {
140+
function BigClass() {
141+
}
142+
${Array.from(new Array(1000)).map((_v, i) =>
143+
`BigClass.prototype.method${i} = function () { return this.myVar; };`,
144+
).join('\n')}
145+
return BigClass;
146+
}());
147+
${clazz}
148+
Clazz.ctorParameters = function () { return []; };
149+
`;
150+
151+
let boOutput: TransformJavascriptOutput;
152+
expect(() => {
153+
boOutput = buildOptimizer({ content: input });
154+
expect(boOutput.emitSkipped).toEqual(false);
155+
}).not.toThrow();
156+
});
130157
});
131158

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

0 commit comments

Comments
 (0)