From b310002a0dcf806fb4000f5239187a48325ebe59 Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:18:36 +0300 Subject: [PATCH 1/6] Use Node.js compile cache --- lib/cjs.cjs | 5 +++++ lib/esm.mjs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/cjs.cjs b/lib/cjs.cjs index ec98743..5668a20 100644 --- a/lib/cjs.cjs +++ b/lib/cjs.cjs @@ -1,3 +1,8 @@ +const mod = require('node:module') + +// to use V8's code cache to speed up instantiation time +mod.enableCompileCache?.() + const { default: npmRunAll } = require('./esm.mjs') // Didn't manage to get this into the last breaking change, so adding a cjs as the primary export diff --git a/lib/esm.mjs b/lib/esm.mjs index 65b1278..5e9123c 100644 --- a/lib/esm.mjs +++ b/lib/esm.mjs @@ -9,6 +9,7 @@ // Requirements // ------------------------------------------------------------------------------ +import { enableCompileCache } from 'node:module' import shellQuote from 'shell-quote' import matchTasks from './match-tasks.js' import readPackageJson from './read-package-json.js' @@ -18,6 +19,9 @@ import runTasks from './run-tasks.js' // Helpers // ------------------------------------------------------------------------------ +// to use V8's code cache to speed up instantiation time +enableCompileCache?.() + const ARGS_PATTERN = /\{(!)?([*@%]|\d+)([^}]+)?}/g const ARGS_UNPACK_PATTERN = /\{(!)?([%])([^}]+)?}/g From ecac95dfbe61514c64f5ae9f319e9408309c5141 Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:40:21 +0300 Subject: [PATCH 2/6] Disable NODE_DISABLE_COMPILE_CACHE in CI so that it does not interfere with the coverage --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c467a99..f26d800 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ on: env: FORCE_COLOR: 2 + NODE_DISABLE_COMPILE_CACHE: 1 jobs: lint: From a2b44b46db3dd917cb73fab68238edd21e20bbad Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 21:35:39 +0300 Subject: [PATCH 3/6] Use namespace import for node:module --- lib/esm.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/esm.mjs b/lib/esm.mjs index 5e9123c..e4e166c 100644 --- a/lib/esm.mjs +++ b/lib/esm.mjs @@ -9,7 +9,7 @@ // Requirements // ------------------------------------------------------------------------------ -import { enableCompileCache } from 'node:module' +import * as mod from 'node:module' import shellQuote from 'shell-quote' import matchTasks from './match-tasks.js' import readPackageJson from './read-package-json.js' @@ -20,7 +20,7 @@ import runTasks from './run-tasks.js' // ------------------------------------------------------------------------------ // to use V8's code cache to speed up instantiation time -enableCompileCache?.() +mod.enableCompileCache?.() const ARGS_PATTERN = /\{(!)?([*@%]|\d+)([^}]+)?}/g const ARGS_UNPACK_PATTERN = /\{(!)?([%])([^}]+)?}/g From cdd601dc4555f9bcdcf020a3e6cee17ee5bd6a0f Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:00:39 +0300 Subject: [PATCH 4/6] Switch from namespace to default import --- lib/esm.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/esm.mjs b/lib/esm.mjs index e4e166c..507d726 100644 --- a/lib/esm.mjs +++ b/lib/esm.mjs @@ -9,7 +9,7 @@ // Requirements // ------------------------------------------------------------------------------ -import * as mod from 'node:module' +import mod from 'node:module' import shellQuote from 'shell-quote' import matchTasks from './match-tasks.js' import readPackageJson from './read-package-json.js' From e909a52738154dd2a89feff2d5e26fa91f3e05ba Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:04:45 +0300 Subject: [PATCH 5/6] Flush compile cache before spawning child process --- lib/run-task.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/run-task.js b/lib/run-task.js index f393dd4..f993cef 100644 --- a/lib/run-task.js +++ b/lib/run-task.js @@ -11,6 +11,7 @@ import fs from 'node:fs' import path from 'node:path' +import mod from 'node:mod' import ansiStyles from 'ansi-styles' import { parse as parseArgs } from 'shell-quote' @@ -208,6 +209,8 @@ export default function runTask (task, options) { } Array.prototype.push.apply(spawnArgs, parseArgs(task).map(cleanTaskArg)) + mod.flushCompileCache?.() + cp = await spawn(execPath, spawnArgs, spawnOptions) // Piping stdio. From f53c3a954a2d34d6ade5ff2c7d11fb3b80591a30 Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:06:42 +0300 Subject: [PATCH 6/6] Fix typo --- lib/run-task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/run-task.js b/lib/run-task.js index f993cef..e898e70 100644 --- a/lib/run-task.js +++ b/lib/run-task.js @@ -11,7 +11,7 @@ import fs from 'node:fs' import path from 'node:path' -import mod from 'node:mod' +import mod from 'node:module' import ansiStyles from 'ansi-styles' import { parse as parseArgs } from 'shell-quote'