diff --git a/build/lib/standalone.ts b/build/lib/standalone.ts index 9813b4fd75e..b7b0fee295f 100644 --- a/build/lib/standalone.ts +++ b/build/lib/standalone.ts @@ -241,8 +241,8 @@ export function createESMSourcesAndResources2(options: IOptions2): void { function toggleComments(fileContents: string): string { let lines = fileContents.split(/\r\n|\r|\n/); let mode = 0; - for (const line of lines) { - + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; if (mode === 0) { if (/\/\/ ESM-comment-begin/.test(line)) { mode = 1; diff --git a/build/lib/treeshaking.ts b/build/lib/treeshaking.ts index 223e8047c1f..060808312e6 100644 --- a/build/lib/treeshaking.ts +++ b/build/lib/treeshaking.ts @@ -464,7 +464,8 @@ function markNodes(languageService: ts.LanguageService, options: ITreeShakingOpt } if (black_queue.length === 0) { - for (const node of gray_queue) { + for (let i = 0; i< gray_queue.length; i++) { + const node = gray_queue[i]; const nodeParent = node.parent; if ((ts.isClassDeclaration(nodeParent) || ts.isInterfaceDeclaration(nodeParent)) && nodeOrChildIsBlack(nodeParent)) { gray_queue.splice(i, 1);