Skip to content

npm pack includes gitignored examples/cloudflare/dist build artifacts #608

Closed

Description

@jimhoyd

Runtime revision and environment

main at $(git rev-parse HEAD 2>/dev/null); found while merging #607.

Minimal reproduction

examples/cloudflare/dist/ is gitignored (.gitignore has dist/), and is written by npm run test:examples:built's Cloudflare build step (node dist/cli.js build --target cloudflare --project examples/cloudflare --out examples/cloudflare/dist). Because examples is listed wholesale in package.json's files, npm pack includes those gitignored files anyway:

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

reports 4 files, ~9.5 KB, that ship in the published tarball only when the local working tree happens to have run the Cloudflare example build first (e.g. in CI's checks job, which runs test:examples:built before test:package:built in the same checkout). A tree that hasn't built the example does not ship them, so the packed contents are nondeterministic depending on build order/history in the working directory.

Relevant output

Confirmed locally: npm run build && npm run test:package:built passes; running npm run test:examples:built first and re-running test:package:built fails the unpacked-size budget (scripts/package-audit.ts), which is how this was found — #607's own legitimate growth ate the remaining headroom.

Suggested fix

Exclude examples/*/dist (and similar per-example build output directories) from the packed files, e.g. an explicit exclude in package.json's files array, or have package-audit.ts assert no gitignored path appears in the pack listing. Separately, #607 raised the unpacked budget from 2450 KiB to 2550 KiB partly to cover this leak; once fixed, consider lowering it back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions