Skip to content

chore: migrate build toolchain from browserify/uglify-js to tsdown#135

Merged
mmktomato merged 13 commits intonulab:masterfrom
lollipop-onl:chore/migrate-to-tsup
Mar 23, 2026
Merged

chore: migrate build toolchain from browserify/uglify-js to tsdown#135
mmktomato merged 13 commits intonulab:masterfrom
lollipop-onl:chore/migrate-to-tsup

Conversation

@lollipop-onl
Copy link
Copy Markdown
Contributor

@lollipop-onl lollipop-onl commented Mar 5, 2026

Migrate the build toolchain from tsc -> browserify -> uglifyjs to tsdown (Rolldown-based bundler), enabling multi-format output for ESM / CJS / IIFE (browser).

fixes #88

Motivation

  • Missing exports map causes type resolution failures under moduleResolution: "node16" / "bundler"
  • No ESM output, preventing tree-shaking for consumers
  • Build pipeline consists of 3 stages with intermediate artifact management scripts

Changes

Before After
dist/backlog.min.js (UMD, 93 KB) dist/index.mjs (ESM, 38 KB), dist/index.cjs (CJS, 39 KB), dist/backlog.iife.min.js (IIFE, 56 KB)
dist/types/*.d.ts dist/index.d.cts (CJS), dist/index.d.mts (ESM)
  • Add nested exports conditions to package.json for correct ESM/CJS type resolution
  • Add browser field pointing to IIFE minified bundle for CDN resolution (unpkg, jsdelivr)
  • Copy IIFE outputs to legacy filenames (backlog.js, backlog.min.js) for backward compatibility
  • Simplify build scripts to a single tsdown command with postbuild hook
  • Update tsconfig.json to target the minimum supported environment (requires fetch / FormData / Promise)

No changes were made to source code (src/), tests (test/), or the public API.

Why tsdown

Selected over tsup, Vite, Rollup, and unbuild for:

  • Rolldown + Oxc based — faster Rust-powered builds
  • Library-first design — native support for ESM / CJS / IIFE output with DTS generation
  • tsup-compatible API — minimal migration effort as the spiritual successor to tsup

Breaking Changes

  • Build target changed from ES5 to ES2022. Since the source code already requires fetch, FormData, and Promise, the effective supported environment range is unchanged.

@lollipop-onl lollipop-onl marked this pull request as ready for review March 5, 2026 14:32
@mmktomato
Copy link
Copy Markdown
Member

This might resolve #88

@mmktomato
Copy link
Copy Markdown
Member

Memo: Conflicts to #133 . Checking internally.

Copy link
Copy Markdown
Member

@mmktomato mmktomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lollipop-onl
I added a comment. Can you check it?

Comment thread tsconfig.json
"esModuleInterop": true,
"skipLibCheck": true
},
"ts-node": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use ts-node, is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being added because mocha runs ts-node internally.
It will no longer be necessary if we can migrate to Vitest or a similar tool in #133.

Replace tsup with tsdown (Rolldown-based bundler) for faster builds.
Add browser field for CDN resolution and copy IIFE outputs to
legacy filenames (backlog.js, backlog.min.js) for backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lollipop-onl lollipop-onl changed the title chore: migrate build toolchain from browserify/uglify-js to tsup chore: migrate build toolchain from browserify/uglify-js to tsdown Mar 11, 2026
Mark dist/ as linguist-generated so GitHub collapses build
artifacts in pull request diffs by default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lollipop-onl
Copy link
Copy Markdown
Contributor Author

@mmktomato
Thank you for the review. Since the previous version, I have replaced the bundler from tsup to tsdown.
In the process, a file named backlog.iife.js is generated, but I am also copying it as backlog.js for backward compatibility.

@lollipop-onl lollipop-onl requested a review from mmktomato March 11, 2026 03:46
@mmktomato
Copy link
Copy Markdown
Member

OK 👍

$ npm publish --dry-run
npm notice
npm notice 📦  backlog-js@0.16.0
npm notice Tarball Contents
npm notice 3.9kB README.md
npm notice 122.4kB dist/backlog.iife.js
npm notice 55.7kB dist/backlog.iife.min.js
npm notice 122.4kB dist/backlog.js
npm notice 55.7kB dist/backlog.min.js
npm notice 360B dist/chunk-CfYAbeIz.mjs
npm notice 39.2kB dist/index.cjs
npm notice 54.2kB dist/index.d.cts
npm notice 54.2kB dist/index.d.mts
npm notice 37.6kB dist/index.mjs
npm notice 2.0kB package.json

Copy link
Copy Markdown
Member

@mmktomato mmktomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lollipop-onl
I added some comments again. Otherwise it looks fine 👍

Comment thread package.json Outdated
Comment thread package.json Outdated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lollipop-onl lollipop-onl requested a review from mmktomato March 21, 2026 16:40
@mmktomato mmktomato merged commit 84e85a6 into nulab:master Mar 23, 2026
@mmktomato
Copy link
Copy Markdown
Member

@lollipop-onl
LGTM!!!

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.

Provide ESM format

2 participants