diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 5f3605b04b..1de41cf9bf 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -149,16 +149,16 @@ export default async function preprocess( filename }); - if (processed) { - if (processed.dependencies) dependencies.push(...processed.dependencies); - source = processed.code; - if (processed.map) { - sourcemap_list.unshift( - typeof(processed.map) === 'string' - ? JSON.parse(processed.map) - : processed.map - ); - } + if (!processed) continue; + + if (processed.dependencies) dependencies.push(...processed.dependencies); + source = processed.code; + if (processed.map) { + sourcemap_list.unshift( + typeof(processed.map) === 'string' + ? JSON.parse(processed.map) + : processed.map + ); } } diff --git a/src/compiler/utils/string_with_sourcemap.ts b/src/compiler/utils/string_with_sourcemap.ts index 7fb38323d4..7f8a0ec1eb 100644 --- a/src/compiler/utils/string_with_sourcemap.ts +++ b/src/compiler/utils/string_with_sourcemap.ts @@ -59,6 +59,8 @@ function merge_tables(this_table: T[], other_table: T[]): [T[], number[], boo } function pushArray(_this: T[], other: T[]) { + // We use push to mutate in place for memory and perf reasons + // We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore) for (let i = 0; i < other.length; i++) { _this.push(other[i]); }