Repository navigation
fix(electron): let verify:exports run outside CI - #46
Merged
Merged
Conversation
`npm run verify:exports` and `node scripts/verify-exports.mjs` both died on a developer machine with `SyntaxError: Unexpected token 'S'`, and passed in CI. The letter is the S of "Scope: all 12 workspace projects". The script parses `npm pack --dry-run --json`. `npm pack` runs `prepack` -- and `prepare`, which is a second build nobody counted -- and both of them shelled back into the package manager. `pnpm run` writes resolution progress to stdout whenever the lockfile does not match the configured registry, which is every invocation behind the proxy registry in `.npmrc` and no invocation in CI, where resolution is clean. So the check ran green on the machine that could not be debugged from and crashed on the machine that could. Two things followed from that nesting, not one. Running a read-only check also rewrote `pnpm-lock.yaml` with rotating `ms-feed-N` shard hostnames, which the NEXT install rejects outright -- SOURCES.md#lockfile-integrity, issue #26. `scripts/build-package.mjs` takes the package manager out of the build. It invokes `tsc` at its installed path rather than by name through `PATH`, and imports `copy-renderer-css.mjs` rather than spawning it. `build:package` and the four `pre*` hooks now point straight at it, so the name every document references still works and nothing shells into pnpm on the way. `verify-exports.mjs` calls `buildPackage()` itself and packs with `--ignore-scripts`. The comment that argued against that flag was right at the time -- skipping scripts would have tested whatever build happened to be on disk -- and is answered by building here, with the same function `prepack` calls, immediately before asking npm what it would pack. Three builds per run become one, and no future line of build output can land in the middle of the JSON. If it somehow does, the parse now names the command and prints what it actually returned. CI calls the npm script rather than the file, now that the script no longer needs a build in front of it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
npm run verify:exportsandnode scripts/verify-exports.mjsboth die on a developer machine:and pass in CI. The
Sis the first letter ofScope: all 12 workspace projects.Why
The script parses
npm pack --dry-run --json.npm packrunsprepack— andprepare, a second build nobody was counting — and both shelled back into the package manager:pnpm runwrites resolution progress to stdout whenever the lockfile does not match the configured registry. That is every invocation behind the proxy registry in.npmrc, and no invocation in CI, where resolution is clean. So the check was green on the machine you cannot debug from and broken on the machine you can. Captured locally, the first 300 bytes of that stdout are pnpm'sScope:andProgress:lines; the JSON is 12KB further down.Two things followed from the nesting, not one. Running this read-only check also rewrote
pnpm-lock.yaml, stamping every one of 1,610 resolutions with a rotatingms-feed-Nshard hostname — the record pnpm then rejects on the next install withERR_PNPM_TARBALL_URL_MISMATCH. See SOURCES.md#lockfile-integrity and #26.What changed
scripts/build-package.mjstakes the package manager out of the build. It invokestscat its installed path rather than by name throughPATH, and importscopy-renderer-css.mjsrather than spawning it.build:packageand the fourpre*hooks point straight at it, so every document that saysnpm run build:packagestill works and nothing shells into pnpm on the way.verify-exports.mjsbuilds, then packs with--ignore-scripts. The comment arguing against that flag was correct when written — skipping scripts would have tested whatever build happened to be on disk. CallingbuildPackage()immediately before, from the same functionprepackcalls, answers it. Three builds per run become one, and no future line of build output can land in the middle of the JSON. If one somehow does, the parse now names the command and prints the first 200 characters it actually returned instead of a bareUnexpected token.CI calls
run verify:exportsrather than the file directly, now that the script no longer needs a build in front of it.Verification
node scripts/verify-exports.mjsfrom a clean checkout: passes,All exports passed (33 renderer modules inspected). Onmainthe same command throws.git statusafter that run: clean.grep -c ms-feed pnpm-lock.yaml→ 0.vitest run: 1124 passed, 67 files.eslint .: clean.verify:docs,verify:neutral,verify:fixture-imports: pass.actionlint: clean.tests/mutation-scope.test.tscaught the new script as unaccounted-for and it is deferred under build(deps): bump the npm-minor-and-patch group across 1 directory with 17 updates #125 alongside every sibling build script.