From 8a1f5c65dda3a7a0528151d6004e8a36dd049366 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 26 Jul 2026 17:36:47 -0500 Subject: [PATCH 1/2] perf: enable the Node.js compile cache --- .changeset/nervous-months-repeat.md | 5 +++++ packages/webpack-cli/bin/cli.js | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/nervous-months-repeat.md diff --git a/.changeset/nervous-months-repeat.md b/.changeset/nervous-months-repeat.md new file mode 100644 index 00000000000..42c7fac2064 --- /dev/null +++ b/.changeset/nervous-months-repeat.md @@ -0,0 +1,5 @@ +--- +"webpack-cli": patch +--- + +perf: enable the Node.js compile cache (`module.enableCompileCache`, available on Node.js >= 22.8.0) to speed up CLI startup diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index b3a6ca5e11a..6d5101f3601 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -2,6 +2,17 @@ "use strict"; +// `module.enableCompileCache` is only available on Node.js >= 22.8.0 +const { enableCompileCache } = require("node:module"); + +if (enableCompileCache) { + try { + enableCompileCache(); + } catch { + // Ignore errors + } +} + // Prefer the local installation of `webpack-cli` when one exists. Run this // before requiring the (heavier) CLI implementation: a delegated run then never // loads it, and `WEBPACK_CLI_SKIP_IMPORT_LOCAL` skips loading `import-local` too. From 7b53c0d4ffd4ec9b38f0cf378c3cd70ea27167c1 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 26 Jul 2026 18:05:30 -0500 Subject: [PATCH 2/2] fixup! --- packages/webpack-cli/bin/cli.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index 6d5101f3601..6e496b42bb9 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -3,6 +3,7 @@ "use strict"; // `module.enableCompileCache` is only available on Node.js >= 22.8.0 +// eslint-disable-next-line n/no-unsupported-features/node-builtins const { enableCompileCache } = require("node:module"); if (enableCompileCache) {