Skip to content

fix(build): ship npm-shrinkwrap.json in published package - #1622

Merged
kriszyp merged 2 commits into
mainfrom
kris/ship-shrinkwrap-in-pack
Jul 10, 2026
Merged

fix(build): ship npm-shrinkwrap.json in published package#1622
kriszyp merged 2 commits into
mainfrom
kris/ship-shrinkwrap-in-pack

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Add npm-shrinkwrap.json to the files allowlist in package.json.

Why

build-tools/build.sh already runs npm shrinkwrap before npm pack, intending to ship a pinned dependency tree. But package.json declares a files allowlist, and that list omitted npm-shrinkwrap.json — so npm pack silently dropped the generated lockfile. Result: every published harper release has shipped with unpinned ^ ranges, and consumers resolve native-addon deps to whatever satisfies the range at install time.

Concretely: npm install harper@5.0.31 floats @datadog/pprof (^5.11.1) onto 5.16.0, whose tarball fails node-gyp rebuild (binding.gyp not found). @harperfast/harper-pro@5.0.31 installs cleanly precisely because its files array already lists npm-shrinkwrap.json, so its shrinkwrap ships and pins pprof to 5.14.1.

Effect

Future releases from this branch ship the shrinkwrap build.sh already generates, so consumers get the exact pinned tree (rocksdb-js, lmdb, argon2, …).

Where to look

  • One line. Verified with npm pack --dry-run: npm-shrinkwrap.json is now listed in the tarball (it was excluded before).
  • Implication worth a nod: a full-tree shrinkwrap gives consumers harper's exact transitive versions (less dedup flexibility). This is the pre-existing intent (build.sh + harper-pro already do this), so it makes harper behave as designed rather than introducing new behavior.

Generated by Claude (Opus 4.8).

build.sh runs `npm shrinkwrap` before `npm pack`, but the package.json
`files` allowlist omitted npm-shrinkwrap.json, so npm pack dropped it and
every release shipped with unpinned `^` dependency ranges. Consumers then
resolved native-addon deps to whatever satisfied the range at install time
(e.g. @datadog/pprof floating onto a build-broken 5.16.0), while harper-pro
— whose files array already lists npm-shrinkwrap.json — installed cleanly.

Add npm-shrinkwrap.json to files so the generated lockfile reaches the
tarball and consumers get the pinned tree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates package.json to include npm-shrinkwrap.json in the packaged files list. There are no review comments, and I have no feedback to provide.

@claude

claude Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Reviewed; no blockers found.

@kriszyp
kriszyp marked this pull request as ready for review July 6, 2026 20:58
@kriszyp

kriszyp commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

CI note: the 3 unit failures (Table.getRecordCount > ...within the time budget 29 == 30, and two Subscription replay > edge cases tests) are pre-existing timing/replay flakes — the same suite passed on Node v24, and this diff only adds one entry to the files array (affects npm pack output only, no runtime/test surface). Not a regression from this PR.

(AI-generated note — Claude Opus 4.8)

@Ethan-Arrowood Ethan-Arrowood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

sent with Claude Fable 5

@kriszyp
kriszyp merged commit baee80d into main Jul 10, 2026
49 of 50 checks passed
@kriszyp
kriszyp deleted the kris/ship-shrinkwrap-in-pack branch July 10, 2026 21:04
kriszyp pushed a commit that referenced this pull request Jul 13, 2026
Follow-up to #1622.

npm shrinkwrap runs after a full npm install in build-tools/build.sh, so the
generated npm-shrinkwrap.json captures devDependencies as well as runtime
ones. Since #1622 started shipping npm-shrinkwrap.json in the published
tarball, consumers now get harper's entire dev tree installed under
node_modules/harper/node_modules/ -- including esbuild (pulled in
transitively via tsx) and its ~30 platform-specific optional binaries.

Those nested @esbuild/<platform> entries land in the consumer's
package-lock.json as "extraneous" rather than resolved-optional, because
they aren't reachable from any declared dependency edge in the consumer's
graph -- they're just mirrored in from harper's bundled shrinkwrap.
Extraneous entries don't get the "optional": true flag written, so npm ci
in consumer projects fails with EBADPLATFORM on platforms other than the
shrinkwrap's original build machine (e.g. @esbuild/aix-ppc64 on
darwin/arm64).

Prune devDependencies before shrinkwrapping so the pinned tree only
contains what harper actually needs at runtime.

Co-authored-by: Peter Brumblay <pbrumblay@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request Jul 13, 2026
Follow-up to #1622.

npm shrinkwrap runs after a full npm install in build-tools/build.sh, so the
generated npm-shrinkwrap.json captures devDependencies as well as runtime
ones. Since #1622 started shipping npm-shrinkwrap.json in the published
tarball, consumers now get harper's entire dev tree installed under
node_modules/harper/node_modules/ -- including esbuild (pulled in
transitively via tsx) and its ~30 platform-specific optional binaries.

Those nested @esbuild/<platform> entries land in the consumer's
package-lock.json as "extraneous" rather than resolved-optional, because
they aren't reachable from any declared dependency edge in the consumer's
graph -- they're just mirrored in from harper's bundled shrinkwrap.
Extraneous entries don't get the "optional": true flag written, so npm ci
in consumer projects fails with EBADPLATFORM on platforms other than the
shrinkwrap's original build machine (e.g. @esbuild/aix-ppc64 on
darwin/arm64).

Prune devDependencies before shrinkwrapping so the pinned tree only
contains what harper actually needs at runtime.
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.

2 participants