Skip to content

tunnel: package hygiene — split build/dist, untrack artifacts, harden publish#66

Open
joelgwebber wants to merge 1 commit into
mainfrom
joel/tunnel-package-hygiene-2
Open

tunnel: package hygiene — split build/dist, untrack artifacts, harden publish#66
joelgwebber wants to merge 1 commit into
mainfrom
joel/tunnel-package-hygiene-2

Conversation

@joelgwebber
Copy link
Copy Markdown
Contributor

@joelgwebber joelgwebber commented May 19, 2026

What changed

.gitignore — Added tunnel/build/ and tunnel/dist/. Both trees are reproducible from source; carrying them in git produced a ~38k-line phantom diff every time bundle was run (rollup was overwriting the tsc output in-place).

tunnel/rollup.config.mjs — Now bundles the entire CLI from build/src/index.jsdist/index.js. The old config only bundled third_party/index.js in-place inside build/, which was the root cause: build and bundle were writing to the same tree and clobbering each other.

tunnel/package.json

  • bin / files point at dist/ instead of build/src/
  • build = clean && tsc (always starts fresh)
  • bundle = build && rollup (clean is already inside build; no duplication)
  • test = build && node --test (self-bootstrapping; no stale-build surprises)
  • prepack = bundle — covers both npm publish and npm pack (replaces prepublishOnly which only ran on publish)
  • Added verify = npm pack --dry-run

tunnel/src/main.ts — Replaced the hard-coded ../../package.json path (only correct from build/src/main.js) with a findPackageJson() walk-up. Works from both build/src/main.js (tsc/dev) and dist/index.js (published bundle).

CLAUDE.md — Added a Tunnel Development section with the script table and a note that build/ / dist/ are gitignored artifacts.

Verified

npm pack --dry-run   → 2 files: dist/index.js + package.json
npm test             → 137/137 pass

… 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) into
  a single dist/index.js. Build (tsc → build/) and bundle (rollup → dist/)
  now write to disjoint trees; no more clobbering.
- 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`).
  - 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.
- CLAUDE.md: add Tunnel Development section documenting the build/test
  scripts and the gitignored artifact trees.
- Version bumps: tunnel 0.1.17 → 0.1.18, plugin 0.2.8 → 0.2.9.

Verified: `npm pack --dry-run` ships exactly two files (dist/index.js +
package.json); all 137 tests pass.
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