Skip to content

fix(pkg): pack tarball inside npm publish --dry-run - #1076

Merged
sxzz merged 1 commit into
rolldown:mainfrom
giaBaoJS:fix/pack-dry-run-env
Sep 16, 2026
Merged

sxzz merged 1 commit into
rolldown:mainfrom
giaBaoJS:fix/pack-dry-run-env

Conversation

@giaBaoJS

Copy link
Copy Markdown
Contributor

AI usage

  • No AI was used in this PR.
  • AI was used: Claude Code + Opus 5
    • I have carefully reviewed the AI-generated content myself.

Description

npm publish --dry-run exports npm_config_dry_run=true to every lifecycle script it runs. When prepublishOnly / prepack runs tsdown with publint or attw enabled, the nested npm pack in packTarball inherits that flag: it prints the tarball name and exits 0 without writing the file, so the build fails with

ERROR  Pack failed: Error: Failed to find packed tarball file in /tmp/tsdown-pack-XXXXXX. Command output:
{ "stdout": "<name>-<version>.tgz\n", "exitCode": 0 }

Minimal repro of the npm behaviour (npm 11.12.1):

$ npm_config_dry_run=true npm pack --pack-destination ./dest --ignore-scripts
...
<name>-0.0.0.tgz
$ ls ./dest
(empty)

src/features/pkg/index.ts spawns the pack command with the process environment unchanged, so the flag leaks into the child. The fix removes npm_config_dry_run from that child environment only.

pnpm ignores the variable and packs normally, so this is npm specific.

Linked Issues

Fixes #1070

Additional context

Tests: src/features/pkg/index.test.ts packs a temporary package twice, once normally and once with npm_config_dry_run=true stubbed. The second test fails on main with the error above and passes with this change; the first one guards against unsetting the variable too aggressively.

Boundary: only the pack subprocess is sanitized. @publint/pack's src/node/pack.js, which this function was copied from, spawns with { nodeOptions: { cwd: dir } } as well and has the same hole, but that lives in another repo. The other subprocesses tsdown spawns (npx create-tsdown, npx tsdown-migrate, the archive extractor in @tsdown/exe, codesign, node --build-sea) do not read npm config, so they are left untouched.

@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

βœ… Deploy Preview for tsdown-main ready!

Name Link
πŸ”¨ Latest commit 396f5a0
πŸ” Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6aa90bb00270c0000832e854
😎 Deploy Preview https://deploy-preview-1076--tsdown-main.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
πŸ€– Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown@1076 -D
npm i https://pkg.pr.new/rolldown/tsdown@1076 -D
yarn add https://pkg.pr.new/rolldown/tsdown@1076.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1076 -D
npm i https://pkg.pr.new/rolldown/tsdown/create-tsdown@1076 -D
yarn add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1076.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1076 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1076 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1076.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1076 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1076 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1076.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1076 -D
npm i https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1076 -D
yarn add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1076.tgz -D

commit: 396f5a0

@sxzz
sxzz merged commit 83f0c57 into rolldown:main Sep 16, 2026
16 checks passed
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.

Pack failed: Error: Failed to find packed tarball file in /tmp/tsdown-pack

2 participants