diff --git a/biome.jsonc b/biome.jsonc index e6e6e1b6080..bc4194f5489 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -50,8 +50,7 @@ "noNonNullAssertion": "off" }, "performance": { - "noDelete": "off", - "noAccumulatingSpread": "off" + "noDelete": "off" }, "security": { "noGlobalEval": "off" diff --git a/packages/rspack-test-tools/src/processor/multi.ts b/packages/rspack-test-tools/src/processor/multi.ts index 187b113c000..e8fe16f4de8 100644 --- a/packages/rspack-test-tools/src/processor/multi.ts +++ b/packages/rspack-test-tools/src/processor/multi.ts @@ -43,40 +43,44 @@ export class MultiTaskProcessor if (typeof _multiOptions.findBundle !== "function") { return []; } - return this.multiCompilerOptions.reduce( - (res, compilerOptions, index) => { - const curBundles = _multiOptions.findBundle!( - index, - context, - compilerOptions - ); - const bundles = Array.isArray(curBundles) - ? curBundles - : curBundles - ? [curBundles] - : []; + const result: string[] = []; + const multiFileIndexMap: Record = + context.getValue(_multiOptions.name, "multiFileIndexMap") || {}; + for (const [ + index, + compilerOptions + ] of this.multiCompilerOptions.entries()) { + const curBundles = _multiOptions.findBundle!( + index, + context, + compilerOptions + ); - const multiFileIndexMap: Record = - context.getValue(_multiOptions.name, "multiFileIndexMap") || {}; - for (const bundle of bundles) { - multiFileIndexMap[bundle] = [ - ...(multiFileIndexMap[bundle] || []), - index - ]; + const bundles = Array.isArray(curBundles) + ? curBundles + : curBundles + ? [curBundles] + : []; + + for (const bundle of bundles) { + if (multiFileIndexMap[bundle]) { + multiFileIndexMap[bundle].push(index); + } else { + multiFileIndexMap[bundle] = [index]; } - context.setValue( - _multiOptions.name, - "multiFileIndexMap", - multiFileIndexMap - ); - return [ - ...res, - ...(Array.isArray(bundles) ? bundles : bundles ? [bundles] : []) - ]; - }, - [] + } + + result.push(...bundles); + } + + context.setValue( + _multiOptions.name, + "multiFileIndexMap", + multiFileIndexMap ); + + return result; }, name: _multiOptions.name }); diff --git a/packages/rspack-test-tools/src/test/context.ts b/packages/rspack-test-tools/src/test/context.ts index fecf3afc9f1..0f4b9996d73 100644 --- a/packages/rspack-test-tools/src/test/context.ts +++ b/packages/rspack-test-tools/src/test/context.ts @@ -121,10 +121,7 @@ export class TestContext implements ITestContext { if (name) { return this.errors.get(name) || []; } - return Array.from(this.errors.values()).reduce( - (res, arr) => [...res, ...arr], - [] - ); + return Array.prototype.concat(...this.errors.values()); } clearError(name?: string) { if (name) { diff --git a/packages/rspack/src/stats/StatsFactory.ts b/packages/rspack/src/stats/StatsFactory.ts index 27c35a5fd3a..d2afed54461 100644 --- a/packages/rspack/src/stats/StatsFactory.ts +++ b/packages/rspack/src/stats/StatsFactory.ts @@ -171,12 +171,13 @@ export class StatsFactory { }); const hooks = this.hooks; - this._caches = Object.keys(hooks).reduce((prev, curr) => { - return { - ...prev, - [curr]: new Map() - }; - }, {} as Cache); + const caches = {} as Cache; + + for (const key of Object.keys(hooks)) { + caches[key as keyof Cache] = new Map(); + } + + this._caches = caches; this._inCreate = false; }