Repository navigation
fix(pkg): pack tarball inside npm publish --dry-run - #1076
Merged
Merged
Conversation
β Deploy Preview for tsdown-main ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tsdown
create-tsdown
@tsdown/css
@tsdown/exe
tsdown-migrate
commit: |
sxzz
approved these changes
Sep 16, 2026
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.
AI usage
Description
npm publish --dry-runexportsnpm_config_dry_run=trueto every lifecycle script it runs. WhenprepublishOnly/prepackruns tsdown withpublintorattwenabled, the nestednpm packinpackTarballinherits that flag: it prints the tarball name and exits 0 without writing the file, so the build fails withMinimal repro of the npm behaviour (npm 11.12.1):
src/features/pkg/index.tsspawns the pack command with the process environment unchanged, so the flag leaks into the child. The fix removesnpm_config_dry_runfrom 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.tspacks a temporary package twice, once normally and once withnpm_config_dry_run=truestubbed. The second test fails onmainwith 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'ssrc/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.