mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-23 10:29:01 -06:00
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:
parent
237b6f61f6
commit
79f919e8f5
@ -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));
|
||||
|
||||
10106
tests/baselines/reference/manyConstExports.js
Normal file
10106
tests/baselines/reference/manyConstExports.js
Normal file
File diff suppressed because it is too large
Load Diff
15001
tests/baselines/reference/manyConstExports.symbols
Normal file
15001
tests/baselines/reference/manyConstExports.symbols
Normal file
File diff suppressed because it is too large
Load Diff
20001
tests/baselines/reference/manyConstExports.types
Normal file
20001
tests/baselines/reference/manyConstExports.types
Normal file
File diff suppressed because it is too large
Load Diff
5002
tests/cases/compiler/manyConstExports.ts
Normal file
5002
tests/cases/compiler/manyConstExports.ts
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user