Skip to content

build: stop paying for an npm install and a skills fetch on every make install - #568

Merged
huichen merged 1 commit into
mainfrom
claude/install-fast
Sep 12, 2026
Merged

huichen merged 1 commit into
mainfrom
claude/install-fast

Conversation

@huichen

@huichen huichen commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

After the dist-mtime fix (#566), a steady-state make install on Windows was ~13s, and two of its steps ran unconditionally even when nothing needed them:

step before
npm install 5.7-13.3s
Vite + worker check 1.7s
tauri/cargo (now clean) ~2.5s
skills (--remote fetch + copy) 2.2-3.2s
copies, make overhead ~1s

npm install: the Makefile branched per platform for this. POSIX compared manifest mtimes against npm's install stamp; Windows ran npm install every time, because cmd/make has no usable mtime test. Measured directly, a no-op npm install --silent costs 6-13s here.

skills: install-skills passed --remote to git submodule update, so every install did a network fetch. Measured: git submodule update --init skills is 0.6s, adding --remote makes it 2.6s, and the whole step was 3.2s.

Fix

scripts/npm-install-if-needed.mjs now does the staleness check for both platforms: it expands the root workspaces globs, compares every manifest (package.json, package-lock.json, each workspace manifest) against node_modules/.package-lock.json — the stamp npm itself writes — and installs only when one is newer or the stamp is missing. Skipping costs one Node start (~0.07s).

Two details worth noting:

  • On Windows npm is npm.cmd, which Node refuses to spawn without a shell (CVE-2024-27980 hardening), while shell: true combined with arguments triggers DEP0190. The script therefore invokes cmd.exe explicitly with a fixed command string — verified with no deprecation warning.
  • The manifest is parsed with a leading BOM stripped. npm tolerates a BOM in package.json (Windows editors add them), JSON.parse does not, and this check runs on every build — a BOM would have broken make install rather than the install it guards.

install-skills no longer passes --remote, so make install uses the submodule commits already checked out and works offline. make update-skills keeps the refresh-from-remote behaviour (the only skills step that needs the network) and is listed in make help.

Verification

Decision logic, probed in a scratch tree with a copy of the script:

case expected result
no stamp (fresh clone, deleted node_modules) install npm install (workspace manifests changed)
unchanged tree skip silent, 0.07s
packages/a/package.json bumped after the stamp install npm install (workspace manifests changed)
package.json with a UTF-8 BOM install, no crash npm install (workspace manifests changed)

The workspaces glob expansion is what case 3 exercises (packages/* → packages/a/package.json); a desktop/mobile manifest is checked the same way.

End-to-end make install numbers on this machine are in the PR comments below.

…e install

Two steps of `make install` ran unconditionally even when nothing needed them.

npm install: the Makefile branched per platform here — POSIX compared manifest mtimes against the npm install stamp, while Windows ran `npm install` every time because cmd/make has no usable mtime test. Measured on Windows, a no-op `npm install --silent` is 6-13s of a ~13s steady-state `make install`. scripts/npm-install-if-needed.mjs now does that check for both platforms: it expands the root `workspaces` globs, compares every manifest against `node_modules/.package-lock.json` (the stamp npm itself writes), and installs only when one is newer or the stamp is missing. The skip costs one Node start (~0.07s). The script goes through cmd.exe explicitly on Windows — npm is npm.cmd, which Node refuses to spawn without a shell, and shell:true plus arguments is deprecated.

skills: `install-skills` passed `--remote` to `git submodule update`, so every install hit the network for a submodule fetch (2.6s of the 3.2s step). `install` now uses the commits already checked out and works offline; `make update-skills` keeps the refresh-from-remote behaviour and is listed in `make help`.

Verified with a scratch-tree probe of the four decision paths: missing stamp installs, unchanged tree skips, a bumped workspace manifest installs, and a manifest with a UTF-8 BOM is parsed rather than crashing (npm tolerates the BOM, JSON.parse does not).
@huichen
huichen enabled auto-merge (squash) September 12, 2026 05:17
@huichen
huichen merged commit dfaf23f into main Sep 12, 2026
12 checks passed
@huichen
huichen deleted the claude/install-fast branch September 12, 2026 05:17
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.

1 participant