Repository navigation
fix(cli): stored docs routes are the same however Node resolves module imports - #12532
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI: required checks, including the test-node shards that run the new test, have not finished on this head yet.
Keeping Node's module resolution out of what the docs-routes and self-audit generators record restores the rule that the build id stands for the package's contents. Packs of this head under Node 24 and Node 22.13 are identical, where the base packs differ in the stored docs routes and the build id, and the new test fails on the base and passes here. Nothing needs to change.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Changeset, same stored routes and build id on every machine that packs the same files: verified. The head packs under Node 24.20 and 22.13.1 match file for file, and the build id hashes the stored routes file (
generate-build-id.mjs:41-66). - Changeset, how Node resolves imports no longer changes which folders the stored routes list: verified. On the head, the default and
--preserve-symlinksruns give byte-identical text (new test). - Before the fix, two packs of one commit differ only in the docs routes and the build id: verified. The base packs under the two Node builds differ in exactly those two files.
- The recorder logs resolution's real-path lookups as a probe of the module's folder, and
assets/codemodsis reached only that way: verified (read-record.mjs:68,:127). It is the only input that differs. --preserve-symlinksreproduces the other machine's file, the same inputs minusassets/codemods: verified.- The hook keeps resolution unrecorded, while module content is still recorded on load: verified.
registry.mjsandintegration-discovery.mjsstay inputs by content. - Before
module.registerHooks(Node 22.15) the run records as before: verified (optional call,published-copy.mjs:75). - The self-audit's stored file is byte-identical before and after: verified.
- Stored docs, template components, command list and manifest record no reads, the component list records only under its Core copy, and the search catalog is unaffected: verified. No
recordReadsappears in those four, the component list's inputs are rooted at the Core copy (generate-component-list.mjs:60), and the search catalog is identical across Node builds. - The routes are unchanged, and the packed docs-routes, packed self-audit, stored-docs and read-record tests pass: verified (235 routes; 182 tests pass).
- After the fix, the cross-machine packs differ in 0 files: verified on a pack without the type-declaration step. That pack holds 2,880 files, so the 3,473 count is not reproduced.
- On the machine that left the folder out, packs before and after are byte-identical: verified with Node 22.13.1.
- One defect restored, no new public API, default or interaction: verified.
- The listed vitest command, prettier and the changeset check pass: verified.
.changeset/docs-routes-same-on-every-machine.md: clearpackages/cli/scripts/published-copy.mjs: clearpackages/cli/scripts/generate-docs-routes.mjs: clearpackages/cli/scripts/generate-self-audit.mjs: clearpackages/cli/scripts/generate-docs-routes.test.mjs: clear
User impact
The same commit, packed on two machines, could give two different CLI tarballs.
assets/docs-routes.generated.jsonlistedassets/codemodsamong its inputs on one machine and not on the other, andclients/cli/build-id.generated.jsonchanged with it. Every other file was identical. The build id is meant to stand for the package's contents, so two builds of the same files must give the same id.Problem and solution fit
recordReads). That window includes the tree's lazy module imports, and Node's module resolution looks up real paths throughfs.realpathSync, which the recorder sees as a probe of each module's folder.assets/codemodsholds only modules, so nothing else in the tree records it.--preserve-symlinks, which makes Node resolve without those lookups, reproduces the other machine's file exactly: the same inputs minusassets/codemods, nothing else.module.registerHooksresolve hook that runs Node's resolution outside the recording. A module's content is still recorded when it loads, as before. The stored inputs are then what the tree read, on every machine.Expected behavior and authority
The stored routes and the build id are functions of the published files (
published-copy.mjs: "what they read there, folders included, is what an installed package holds"). No record states these generators' inputs.Smallest restoration
published-copy.mjs:resolutionUnrecorded(pkg), runner source that keeps module resolution out of the copy's recorder. Beforemodule.registerHooks(Node 22.15) the run records as it did before.generate-docs-routes.mjsandgenerate-self-audit.mjs(the same recording pattern) use it. The self-audit's stored file is byte-identical before and after on this machine; it gets the hook so the same drift cannot reach it.Evidence
assets/codemodsis only in the default run's inputs, not the--preserve-symlinksrun's.assets/codemods, which matches the machine that left it out.pnpm packin packages/cli, the same commit on two machines with different Node builds): before the change, the two packs differ indocs-routes.generated.jsonandbuild-id.generated.json. After it, 0 of 3,473 files differ, and the uncompressed tar is byte-identical, headers included. On the machine that left the folder out, the packs before and after are byte-identical .tgz files. The compressed bytes still differ between the two Node builds, because each Node's zlib compresses differently; the contents do not.Scope
Components: CLI publish-time generators
Testing
CI=1 pnpm vitest run --project node packages/cli/scripts packages/cli/test/packed-docs-routes.test.mjs packages/cli/test/packed-self-audit.test.mjs packages/cli/test/packed-stored-docs.test.mjs packages/cli/foundation/doc-compiler/doc-loads.test.mjs packages/cli/foundation/fs/read-record.test.mjspnpm check:changesets