Repository navigation
fix: exclude examples/*/dist build artifacts from npm pack - #631
Merged
Merged
Conversation
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
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.
Summary
examples/cloudflare/dist/is gitignored, butnpm packstill included it becauseexamplesis listed wholesale inpackage.json'sfilesarray. Since that directory is only written locally bynpm 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.examples/*/distvia a negation entry infiles(!examples/*/dist/**) — verified empirically that npm'sfilesfield does honor negated glob patterns (there's already a precedent for this:!dist/scripts), so no.npmignoreor directory restructuring was needed.scripts/package-audit.ts: it now checks every pathnpm packwould 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 owndist/build output is exempted, since that's deliberately gitignored (never committed) yet is always the intended, freshly regenerated release content.Verification
returns nothing (previously reported 4 files, ~9.5 KB).
Also ran, all passing:
npm run typechecknpm run test:package(616133packed bytes,2565483unpacked bytes,439files — 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'spassword hashing queues briefly under contention instead of refusing every caller past two (#464)— but it is unrelated to this change (nopackages/authfiles 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.package-audit.tsassertion actually catches the regression: reverting thefilesfix locally and rerunningtest:package:builtfails withGitignored paths present in packed release (nondeterministic local build artifacts, see #608): .../examples/cloudflare/dist/*.js.Closes #608
🤖 Generated with Claude Code