Skip to content

Commit

Permalink
chore(infra/biome): enable noAccumulatingSpread (#7492)
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda authored Aug 8, 2024
1 parent 2bd905d commit 921b522
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
3 changes: 1 addition & 2 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"noNonNullAssertion": "off"
},
"performance": {
"noDelete": "off",
"noAccumulatingSpread": "off"
"noDelete": "off"
},
"security": {
"noGlobalEval": "off"
Expand Down
64 changes: 34 additions & 30 deletions packages/rspack-test-tools/src/processor/multi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,44 @@ export class MultiTaskProcessor<T extends ECompilerType>
if (typeof _multiOptions.findBundle !== "function") {
return [];
}
return this.multiCompilerOptions.reduce<string[]>(
(res, compilerOptions, index) => {
const curBundles = _multiOptions.findBundle!(
index,
context,
compilerOptions
);

const bundles = Array.isArray(curBundles)
? curBundles
: curBundles
? [curBundles]
: [];
const result: string[] = [];
const multiFileIndexMap: Record<string, number[]> =
context.getValue(_multiOptions.name, "multiFileIndexMap") || {};
for (const [
index,
compilerOptions
] of this.multiCompilerOptions.entries()) {
const curBundles = _multiOptions.findBundle!(
index,
context,
compilerOptions
);

const multiFileIndexMap: Record<string, number[]> =
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
});
Expand Down
5 changes: 1 addition & 4 deletions packages/rspack-test-tools/src/test/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 7 additions & 6 deletions packages/rspack/src/stats/StatsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

2 comments on commit 921b522

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-08-08 2bd905d) Current Change
10000_development-mode + exec 2.32 s ± 27 ms 2.33 s ± 27 ms +0.21 %
10000_development-mode_hmr + exec 701 ms ± 7.3 ms 702 ms ± 4.3 ms +0.23 %
10000_production-mode + exec 2.85 s ± 23 ms 2.86 s ± 46 ms +0.59 %
arco-pro_development-mode + exec 1.89 s ± 75 ms 1.9 s ± 72 ms +0.46 %
arco-pro_development-mode_hmr + exec 434 ms ± 2.4 ms 433 ms ± 2.5 ms -0.09 %
arco-pro_production-mode + exec 3.52 s ± 286 ms 3.49 s ± 197 ms -0.76 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.54 s ± 235 ms 3.59 s ± 239 ms +1.29 %
threejs_development-mode_10x + exec 1.72 s ± 15 ms 1.72 s ± 18 ms +0.22 %
threejs_development-mode_10x_hmr + exec 826 ms ± 9.5 ms 830 ms ± 3.5 ms +0.44 %
threejs_production-mode_10x + exec 5.53 s ± 29 ms 5.52 s ± 32 ms -0.25 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
nx ❌ failure
rspress ✅ success
rsbuild ❌ failure
examples ✅ success

Please sign in to comment.