Skip to content

build: migrate bundling from rollup+tsc to tsdown#58

Open
alexvictoor wants to merge 1 commit into
masterfrom
chore/migrate-to-tsdown
Open

build: migrate bundling from rollup+tsc to tsdown#58
alexvictoor wants to merge 1 commit into
masterfrom
chore/migrate-to-tsdown

Conversation

@alexvictoor

Copy link
Copy Markdown
Member

Replace the two-tool build (tsc for per-file CJS + Rollup for the UMD bundle) with a single tsdown (Rolldown + Oxc) config. Benchmarked against rollup, esbuild and tsup on this repo: tsdown builds ~2.3x faster than the old tsc+rollup step while emitting ESM + CJS + UMD + bundled .d.ts from one command, with equivalent output size.

  • Add tsdown.config.ts: unbundled ESM/CJS (per-module, so consumers can tree-shake unused histogram types and the ~33kB inlined WASM blob) plus a bundled UMD build kept at dist/hdrhistogram.umd.js for CDN back-compat.
  • package.json: add "module", a proper "exports" map (import/require + types), "sideEffects": false, and prepublishOnly. Fix "files" to ["dist"] (was ["."], which published the whole repo root). Drop rollup, the four @rollup/* plugins and the dead ts-loader; add tsdown.
  • Delete rollup.config.js.
  • README: rewrite the Tree Shaking section for the new tree-shakeable named imports and document the v3->v4 packaging change.
  • Docs: fix engines.node in the v3->v4 migration notes (>=22, matching package.json and CI); "Node 18+" is kept only as the Compression Streams API availability baseline.

Replace the two-tool build (tsc for per-file CJS + Rollup for the UMD
bundle) with a single tsdown (Rolldown + Oxc) config. Benchmarked against
rollup, esbuild and tsup on this repo: tsdown builds ~2.3x faster than the
old tsc+rollup step while emitting ESM + CJS + UMD + bundled .d.ts from one
command, with equivalent output size.

- Add tsdown.config.ts: unbundled ESM/CJS (per-module, so consumers can
  tree-shake unused histogram types and the ~33kB inlined WASM blob) plus a
  bundled UMD build kept at dist/hdrhistogram.umd.js for CDN back-compat.
- package.json: add "module", a proper "exports" map (import/require +
  types), "sideEffects": false, and prepublishOnly. Fix "files" to ["dist"]
  (was ["."], which published the whole repo root). Drop rollup, the four
  @rollup/* plugins and the dead ts-loader; add tsdown.
- Delete rollup.config.js.
- README: rewrite the Tree Shaking section for the new tree-shakeable
  named imports and document the v3->v4 packaging change.
- Docs: fix engines.node in the v3->v4 migration notes (>=22, matching
  package.json and CI); "Node 18+" is kept only as the Compression
  Streams API availability baseline.
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.

1 participant