Fixes stack overflow when exporting a lot in commonjs (#38994)

* Fixes stack overflow when exporting a lot in commonjs

Fixes #38691

* Add missing test files
This commit is contained in:
Eric Anderson 2020-09-04 12:01:59 -04:00 committed by GitHub
parent 237b6f61f6
commit 79f919e8f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50123 additions and 1 deletions

View File

@ -99,7 +99,19 @@ namespace ts {
append(statements, createUnderscoreUnderscoreESModule());
}
if (length(currentModuleInfo.exportedNames)) {
append(statements, factory.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev), factory.createVoidZero() as Expression)));
const chunkSize = 50;
for (let i=0; i<currentModuleInfo.exportedNames!.length; i += chunkSize) {
append(
statements,
factory.createExpressionStatement(
reduceLeft(
currentModuleInfo.exportedNames!.slice(i, i + chunkSize),
(prev, nextId) => factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(idText(nextId))), prev),
factory.createVoidZero() as Expression
)
)
);
}
}
append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff