Skip to content

fix(electron): let verify:exports run outside CI - #46

Merged
stuffbucket merged 1 commit into
mainfrom
fix/verify-exports-without-nested-pnpm
Sep 6, 2026
Merged

stuffbucket merged 1 commit into
mainfrom
fix/verify-exports-without-nested-pnpm

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

npm run verify:exports and node scripts/verify-exports.mjs both die on a developer machine:

SyntaxError: Unexpected token 'S', "Scope: all"... is not valid JSON

and pass in CI. The S is the first letter of Scope: all 12 workspace projects.

Why

The script parses npm pack --dry-run --json. npm pack runs prepack — and prepare, a second build nobody was counting — and both shelled back into the package manager:

"build:package": "pnpm run build:host && pnpm run build:renderer",
"prepack": "pnpm run build:package",
"prepare": "pnpm run build:package",

pnpm run writes 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's Scope: and Progress: 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 rotating ms-feed-N shard hostname — the record pnpm then rejects on the next install with ERR_PNPM_TARBALL_URL_MISMATCH. See SOURCES.md#lockfile-integrity and #26.

What changed

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 point straight at it, so every document that says npm run build:package still works and nothing shells into pnpm on the way.

verify-exports.mjs builds, 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. Calling buildPackage() immediately before, from the same function prepack calls, 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 bare Unexpected token.

CI calls run verify:exports rather than the file directly, now that the script no longer needs a build in front of it.

Verification

  • node scripts/verify-exports.mjs from a clean checkout: passes, All exports passed (33 renderer modules inspected). On main the same command throws.
  • git status after 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.ts caught 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.

`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]>
@stuffbucket
stuffbucket merged commit 8817eb3 into main Sep 6, 2026
6 checks passed
@stuffbucket
stuffbucket deleted the fix/verify-exports-without-nested-pnpm branch September 6, 2026 05:43
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