Skip to content

Commit 9c27f63

Browse files
committed
fix: watching.close() is slow
1 parent 140b621 commit 9c27f63

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

bench.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const isScheduled = !!process.env.SCHEDULED_JOB;
22

33
// HMR will run 10 times in build plugin, so we should not start multiple instances of Rspack.
44
// However, we still need to run multiple instances of Rspack when executing scheduled tasks for longer runtimes.
5-
const hmrRuns = isScheduled ? 10 : 1;
5+
const hmrRuns = isScheduled ? 10 : 5;
66

77
export default {
88
jobs: [

lib/scenarios/build-plugin.cjs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ module.exports = class BuildPlugin {
88
compiler.hooks.watchRun.tap("BuildPlugin", () => {
99
isWatching = true;
1010
});
11-
(compiler.hooks.afterDone || compiler.hooks.done).tap("BuildPlugin", () => {
12-
setTimeout(() => {
13-
if (counter === WARMUP_BUILDS) console.log("#!# start");
14-
if (isWatching && counter <= TOTAL_BUILDS) console.log("#!# next");
15-
}, 10);
11+
compiler.hooks.afterDone.tap("BuildPlugin", () => {
12+
if (counter === WARMUP_BUILDS) console.log("#!# start");
13+
if (isWatching && counter <= TOTAL_BUILDS) console.log("#!# next");
1614
});
1715
compiler.hooks.done.tap("BuildPlugin", stats => {
1816
if (isWatching) {
1917
counter++;
2018
if (counter <= WARMUP_BUILDS) return;
2119
if (counter > TOTAL_BUILDS) {
22-
if (compiler.watching) {
23-
compiler.watching.close();
24-
} else {
25-
process.nextTick(() => process.exit(0));
26-
}
20+
process.nextTick(() => process.exit(0));
2721
}
2822
}
2923
const { logging, time } = stats.toJson({
@@ -69,10 +63,7 @@ module.exports = class BuildPlugin {
6963
if (type !== "time") return;
7064
const ms = args[1] * 1000 + args[2] / 1000000;
7165
console.log(
72-
`#!# ${name}.${args[0].replace(
73-
/restore cache content \d.+$/,
74-
"restore cache content"
75-
)} = ${ms}`
66+
`#!# ${name}.${args[0].replace(/restore cache content \d.+$/, "restore cache content")} = ${ms}`
7667
);
7768
};
7869
}

pnpm-lock.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)