chore(build): hash inputs in smart-build cache check#1219
Merged
John-David Dalton (jdalton) merged 1 commit intomainfrom Apr 17, 2026
Merged
chore(build): hash inputs in smart-build cache check#1219John-David Dalton (jdalton) merged 1 commit intomainfrom
John-David Dalton (jdalton) merged 1 commit intomainfrom
Conversation
Extends `needsBuild()` in the smart-build script so it rebuilds when the
bundler configs, build scripts, source, lockfile, or Node version change
— not only when the dist output is missing.
How it works:
- Each package entry declares a list of input globs.
- We SHA-256 the file paths + contents into a "build signature."
- The signature is written alongside the output (e.g.
`packages/cli/dist/index.js.build-signature`) after a successful build.
- The next smart build re-hashes inputs; if the hash differs, we rebuild.
Force (`--force`) still bypasses everything.
Signature sidecars are gitignored.
Bill Li (billxinli)
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this exists
Today's smart-build cache check is output-only: if
packages/cli/dist/index.jsexists, it skips. That's fine for "the dist is there" but it misses every other reason a rebuild is needed.The pain point I hit: bumping
target: 'node18'→'node25'inpackages/cli/.config/esbuild.cli.mts, runningpnpm build, seeing "CLI Package: skipped (up to date)", getting confused,--force-ing, and realizing the smart build had silently served stale output for a config change. That's a junior-dev-hostile trap — you change the bundler's behavior, the tool says "up to date", and you have to know to distrust it.Other things that fall into the same bucket:
pnpm-lock.yamlchanged (dependency bump) → old bundle, stale deps.packages/build-infra/lib/**changed (shared build helpers) → stale bundle..node-versionbumped → stale bundle targeting the old runtime floor.What this changes
needsBuild()now also rebuilds when the inputs change, not just when the output is missing.How it works:
.node-version).dist/index.js.build-signature(gitignored).Why content hashing instead of mtime:
git checkout,rebase, branch switching all rewrite mtimes even when content is identical. mtime-based checks thrash on every branch switch.--forcestill bypasses everything.Inputs currently tracked for the CLI:
packages/cli/.config/**/*.{mts,ts,json}packages/cli/scripts/**/*.{mts,ts}packages/cli/src/**/*.{mts,ts,cts,json}packages/cli/package.json,tsconfig.jsonpackages/build-infra/lib/**/*.{mts,ts},package.jsonpnpm-lock.yaml.node-versionTest plan