Skip to content

chore: more efficient script execution#862

Merged
adalinesimonian merged 3 commits intomainfrom
more-efficient-scripts
Mar 14, 2026
Merged

chore: more efficient script execution#862
adalinesimonian merged 3 commits intomainfrom
more-efficient-scripts

Conversation

@adalinesimonian
Copy link
Copy Markdown
Member

Increase the speed and efficacy of our npm scripts by implementing the following changes:

  • Add wireit to cache and manage dependencies between npm scripts. Scripts that are not meaningfully cacheable are left as plain scripts.
  • Add wireit's GitHub Actions caching so that CI benefits from the same caching as local development.
  • Replace npm run with node --run across scripts, CI, VS Code tasks, and documentation to avoid npm's startup overhead on every invocation.
  • Replace tsx with node --experimental-transform-types for faster TypeScript execution in scripts.

When inputs haven't changed since the last run, wireit skips the command entirely. Dependency ordering between scripts is declared in package.json rather than encoded into chained shell commands, so wireit can also parallelise independent tasks and avoid redundant work when multiple scripts share the same dependency.

This means no more of the annoying hassle of running npm run lint, then Prettier failing, then fixing the Prettier issues and having to run npm run lint again to get the ESLint results, and so on; or, the alternative, juggling the different lint subscripts manually. Now we just run node --run lint once, everything is done in parallel. And if only let's say the readme is changed, and we already ran node --run lint before, then the next time we run it, only Prettier and cspell will run, and ESLint will be skipped because its inputs haven't changed. This saves a lot of time and annoyance when running scripts repeatedly during development.

In CI, wireit's GitHub Actions caching means that re-runs and subsequent pushes to the same PR can skip scripts whose inputs haven't changed since the last workflow run, rather than rebuilding everything from scratch every time.

The other two changes speed up script execution by avoiding spawning extra processes. node --run skips the npm startup overhead, and node --experimental-transform-types skips the overhead of starting up tsx when Node.js can now transform TypeScript natively.

@adalinesimonian adalinesimonian self-assigned this Mar 13, 2026
@adalinesimonian adalinesimonian requested a review from a team as a code owner March 13, 2026 13:53
@adalinesimonian adalinesimonian force-pushed the more-efficient-scripts branch from 1ab2e96 to 83acf47 Compare March 13, 2026 13:58
--experimental-transform types is being removed in Node.js 26, but the
functionality in --experimental-strip-types has been stable since 22.18.

We use 22.17.0 due to VS Code 1.103, the lowest version we support,
bundling 22.17. If we up the lowest supported version of VS Code to
1.104, then we will have Node.js 22.18 at minimum and simply get rid of
the flag.
Copy link
Copy Markdown
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good improvements, thank you!

We do a lot on the CI for the extension, and so it's great to see efficiency improvements.

@adalinesimonian
Copy link
Copy Markdown
Member Author

@jeddy3 Thanks! :) Do we need to allowlist the google/wireit action?

@jeddy3
Copy link
Copy Markdown
Member

jeddy3 commented Mar 14, 2026

Do we need to allowlist the google/wireit action?

Done.

@adalinesimonian adalinesimonian merged commit ceb448e into main Mar 14, 2026
43 of 45 checks passed
@adalinesimonian adalinesimonian deleted the more-efficient-scripts branch March 14, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants