Skip to content

Resolve deps/configs within task functions, and use nano-spawn to run bins#874

Merged
ecraig12345 merged 3 commits into
mainfrom
nano-spawn
Jun 11, 2026
Merged

Resolve deps/configs within task functions, and use nano-spawn to run bins#874
ecraig12345 merged 3 commits into
mainfrom
nano-spawn

Conversation

@ecraig12345

Copy link
Copy Markdown
Member

Previously, some tasks (esbuildTask, prettierTask, tarTask, tscTask, webpackCliTask) would resolve dependencies and/or configs when the task creation function was called, rather than when the task was run. This means there's the perf hit for resolving each of those deps/files on every config load, even if the task isn't used, which adds up in large repos.

This PR updates the tasks above to do all their resolution within the task function itself (the other tasks already did this).

Related changes:

  • For all tasks which run CLIs from dependencies (tsc, prettier, etc), make the binary resolution more resilient across package versions by looking at package.json bin instead of hardcoding. Also run the binaries with nano-spawn for better built-in error handling and other features.
  • In nodeExecTask, run tasks with nano-spawn instead of cross-spawn. Behavior is similar, but it changes the spawnOptions type slightly, and the env option is always merged with the current process.env.

Introducing nano-spawn (which is ESM) requires running Jest tests via cross-env NODE_OPTIONS='--experimental-vm-modules' jest ... to make the async imports work.

Fixes #814

@ecraig12345 ecraig12345 merged commit 4b6ef79 into main Jun 11, 2026
7 checks passed
@ecraig12345 ecraig12345 deleted the nano-spawn branch June 11, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use execa or nano-spawn internally for tasks

1 participant