Skip to content

Commit b0a2024

Browse files
authored
perf: enable the Node.js compile cache (#4818)
* perf: enable the Node.js compile cache * fixup!
1 parent 53f6d72 commit b0a2024

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": patch
3+
---
4+
5+
perf: enable the Node.js compile cache (`module.enableCompileCache`, available on Node.js >= 22.8.0) to speed up CLI startup

packages/webpack-cli/bin/cli.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
"use strict";
44

5+
// `module.enableCompileCache` is only available on Node.js >= 22.8.0
6+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
7+
const { enableCompileCache } = require("node:module");
8+
9+
if (enableCompileCache) {
10+
try {
11+
enableCompileCache();
12+
} catch {
13+
// Ignore errors
14+
}
15+
}
16+
517
// Prefer the local installation of `webpack-cli` when one exists. Run this
618
// before requiring the (heavier) CLI implementation: a delegated run then never
719
// loads it, and `WEBPACK_CLI_SKIP_IMPORT_LOCAL` skips loading `import-local` too.

0 commit comments

Comments
 (0)