diff --git a/packages/rspack-cli/bin/rspack.js b/packages/rspack-cli/bin/rspack.js index 1b1c557b82a..1510c6b18dc 100755 --- a/packages/rspack-cli/bin/rspack.js +++ b/packages/rspack-cli/bin/rspack.js @@ -1,4 +1,17 @@ #!/usr/bin/env node +const nodeModule = require("node:module"); + +// enable on-disk code caching of all modules loaded by Node.js +// requires Nodejs >= 22.8.0 +const { enableCompileCache } = nodeModule; +if (enableCompileCache) { + try { + enableCompileCache(); + } catch { + // ignore errors + } +} + const { RspackCLI } = require("../dist/index"); async function runCLI() {