Skip to content

fix: exclude examples/*/dist build artifacts from npm pack - #631

Merged
jimhoyd merged 3 commits into
mainfrom
claude/fix-npm-pack-examples-dist-608
Sep 24, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/fix-npm-pack-examples-dist-608

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • examples/cloudflare/dist/ is gitignored, but npm pack still included it because examples is listed wholesale in package.json's files array. Since that directory is only written locally by npm run test:examples:built's Cloudflare build step, the published tarball's contents depended on build order/history in the working tree rather than committed source.
  • Excludes examples/*/dist via a negation entry in files (!examples/*/dist/**) — verified empirically that npm's files field does honor negated glob patterns (there's already a precedent for this: !dist/scripts), so no .npmignore or directory restructuring was needed.
  • Adds a defense-in-depth assertion in scripts/package-audit.ts: it now checks every path npm pack would ship against the repository's ignore rules and fails loudly if any gitignored path appears, so a similar leak elsewhere can't slip in silently. The package's own dist/ build output is exempted, since that's deliberately gitignored (never committed) yet is always the intended, freshly regenerated release content.
  • Lowers the unpacked-size budget from 2550 KiB back to 2540 KiB — the ~9.5 KiB the leak was accounting for, per fix(core): actionable authoring errors, strict request fixtures and JSON 422s #607/npm pack includes gitignored examples/cloudflare/dist build artifacts #608's own comments. Confirmed actual current usage (2565483 bytes) comfortably fits with ~35 KiB of headroom remaining.

Verification

npm run build && npm run test:examples:built && npm pack --dry-run --json | jq '.[0].files[] | select(.path | contains("cloudflare/dist"))'

returns nothing (previously reported 4 files, ~9.5 KB).

Also ran, all passing:

  • npm run typecheck
  • npm run test:package (616133 packed bytes, 2565483 unpacked bytes, 439 files — under the new 2540 KiB budget)
  • npm run verify (full lint/typecheck/build/test/workspace-verify run). One test failed on the first run — packages/auth's password hashing queues briefly under contention instead of refusing every caller past two (#464) — but it is unrelated to this change (no packages/auth files touched) and is a timing-sensitive concurrency test; it passed on an isolated rerun and is consistent with this environment being under heavy concurrent load from other sessions, not a regression from this PR.
  • Manually verified the new package-audit.ts assertion actually catches the regression: reverting the files fix locally and rerunning test:package:built fails with Gitignored paths present in packed release (nondeterministic local build artifacts, see #608): .../examples/cloudflare/dist/*.js.

Closes #608

🤖 Generated with Claude Code

jimhoyd and others added 3 commits September 23, 2026 22:28
examples/cloudflare/dist/ is gitignored but was still included in the
published tarball because `examples` is listed wholesale in package.json's
files array, making the packed contents depend on whether
test:examples:built had run locally before packaging.

Exclude examples/*/dist via a negation entry in files (npm does support
this pattern), and have scripts/package-audit.ts assert that no gitignored
path ships (dist/ itself excepted, since that build output is deliberately
gitignored yet always the intended, freshly regenerated release content).
Also lower the unpacked-size budget back from 2550 KiB to 2540 KiB, the
~9.5 KiB the leak was accounting for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	scripts/package-audit.ts
@jimhoyd
jimhoyd merged commit 59cc7ce into main Sep 24, 2026
21 checks passed
@jimhoyd
jimhoyd deleted the claude/fix-npm-pack-examples-dist-608 branch September 24, 2026 11:26
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.

npm pack includes gitignored examples/cloudflare/dist build artifacts

1 participant