tunnel: package hygiene — split build/dist, untrack artifacts, harden publish#56
Open
joelgwebber wants to merge 1 commit intomainfrom
Open
tunnel: package hygiene — split build/dist, untrack artifacts, harden publish#56joelgwebber wants to merge 1 commit intomainfrom
joelgwebber wants to merge 1 commit intomainfrom
Conversation
… publish
Cleans up the publish flow so the tarball is always self-contained and
local builds can't get into a half-built state.
- .gitignore: untrack tunnel/build/ and tunnel/dist/. tsc and rollup outputs
are reproducible from sources; carrying them in git produced a 38k-line
phantom diff every time `bundle` was run because rollup overwrote the
small re-export with the full bundled output at the same path.
- rollup.config.mjs: bundle the entire CLI (input build/src/index.js, where
the Node-version-check entrypoint lives) into a single dist/index.js.
Build (tsc → build/) and bundle (rollup → dist/) now write to disjoint
trees; no more clobbering. Shebang carries through from index.ts so the
banner option is gone.
- package.json:
- bin/files now point at dist/.
- clean wipes both build/ and dist/.
- build = clean && tsc (always a fresh build).
- bundle = build && rollup.
- test = build && node --test (self-bootstrapping).
- prepack = bundle (covers both `npm pack` and `npm publish` — more
robust than prepublishOnly, which only runs on publish).
- verify = npm pack --dry-run (quick "what would ship?" check).
- prepublishOnly removed (covered by prepack).
- main.ts: walk up to find package.json instead of hard-coding ../..,
since the bundled file at dist/index.js sits one level above package.json
and the tsc output at build/src/main.js sits two levels above.
Verified: `npm pack --dry-run` ships exactly two files (dist/index.js +
package.json); installing the tarball into a clean dir and running the
binary returns the expected version with no node_modules pulls.
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
Cleans up the tunnel package's publish flow so the tarball is always self-contained and local builds can't get into a half-built state.
The phantom-diff problem. `rollup.config.mjs` had `input` and `output` pointing at the same file (`build/src/third_party/index.js`). `npm run build` produced a 6-line ESM re-export there; `npm run bundle` overwrote it with a 38k-line bundled artifact. The state on disk swung between the two depending on which command ran last, producing perpetual "changes" in `build/` whenever the artifact was committed.
The fix.
Test plan
🤖 Generated with Claude Code