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
  • Loading branch information
filipesilva committed Jun 1, 2018
1 parent bee9f67 commit 4ab0d68
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -134,8 +134,8 @@
"semver": "^5.3.0",
"semver-intersect": "^1.1.2",
"source-map": "^0.5.6",
"source-map-support": "^0.5.0",
"source-map-loader": "^0.2.3",
"source-map-support": "^0.5.0",
"stats-webpack-plugin": "^0.6.2",
"style-loader": "^0.21.0",
"stylus": "^0.54.5",
Expand All @@ -147,7 +147,7 @@
"ts-node": "^5.0.0",
"tslint": "^5.9.1",
"tsutils": "~2.22.2",
"typescript": "~2.7.2",
"typescript": "^2.9.1",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1",
"webpack": "~4.6.0",
Expand Down
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 @@ -127,6 +128,29 @@ describe('build-optimizer', () => {

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

it(`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 4ab0d68

Please sign in to comment.