Skip to content

Commit

Permalink
fix(cli): should close compiler after building (#6835)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jun 17, 2024
1 parent c94901d commit 553f785
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/rspack-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,26 @@ export class BuildCommand implements RspackCommand {
errorHandler
);

if (!compiler) return;
if (cli.isWatch(compiler)) {
if (!compiler || cli.isWatch(compiler)) {
return;
} else {
compiler.run(errorHandler);
}

compiler.run(
(error: Error | null, stats: Stats | MultiStats | undefined) => {
// If there is a compilation error, the close method should not be called,
// Otherwise Rspack may generate invalid caches.
if (error || stats?.hasErrors()) {
errorHandler(error, stats);
} else {
compiler.close(closeErr => {
if (closeErr) {
logger.error(closeErr);
}
errorHandler(error, stats);
});
}
}
);
}
);
}
Expand Down

2 comments on commit 553f785

@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-06-16 bdc2037) Current Change
10000_development-mode + exec 2.24 s ± 13 ms 2.21 s ± 23 ms -1.22 %
10000_development-mode_hmr + exec 741 ms ± 6.2 ms 738 ms ± 9.9 ms -0.28 %
10000_production-mode + exec 2.59 s ± 28 ms 2.57 s ± 22 ms -0.98 %
arco-pro_development-mode + exec 1.92 s ± 102 ms 1.92 s ± 86 ms -0.13 %
arco-pro_development-mode_hmr + exec 442 ms ± 3.1 ms 442 ms ± 3.5 ms -0.05 %
arco-pro_production-mode + exec 3.52 s ± 77 ms 3.54 s ± 88 ms +0.78 %
threejs_development-mode_10x + exec 1.47 s ± 16 ms 1.46 s ± 12 ms -0.16 %
threejs_development-mode_10x_hmr + exec 800 ms ± 2.2 ms 802 ms ± 11 ms +0.16 %
threejs_production-mode_10x + exec 4.79 s ± 25 ms 4.77 s ± 22 ms -0.34 %

@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 ✅ success
rspress ✅ success
rsbuild ✅ success
compat ✅ success
examples ✅ success

Please sign in to comment.