Skip to content

Commit 7c6af4e

Browse files
committed
build: replace rollup/babel/terser build with tsdown
Collapse the hand-rolled Rollup orchestrator (scripts/configs.cjs + config-types.cjs + build.main.cjs, 373 lines) and 8 build devDeps into one tsdown.config.ts (rolldown engine + built-in dts). Chosen over tsup after a problem-blind Codex assessment and a spike: tsdown emits constructor-direct CJS (require('fuse.js') === Fuse) and named worker CJS automatically, no footer hacks. Behavior-preserving on the public surface: - identical 15-file dist set (12 runtime + 3 dts) - CJS require() contract unchanged; named fuse-worker.cjs export preserved - feature-flag DCE intact (basic build strips logical/extended/token) - dev/prod default-export split preserved - Fuse.version injected via define (bare __VERSION__ + ambient declare; honors process.env.VERSION for releases) Worker-URL resolution no longer depends on a bundler's import.meta.url codegen: a per-format __WORKER_IS_CJS__ define routes browser-CJS to a document base while ESM keeps the literal new URL('./fuse.worker.mjs', import.meta.url) so bundlers still detect and rewrite the worker asset. test/worker-url.test.js gates node-ESM, node-CJS, browser-ESM (Vite), and browser-CJS. test/cjs-interop.test.js gates require() === constructor for every lib cjs plus the named worker cjs. Sizes: minified artifacts are 287-313 bytes smaller raw; gzip is +8..+28 bytes (<=0.4%, accepted) since rolldown's minifier compresses marginally worse than Terser. Build/release now requires Node >=22.18 (tsdown engines): CI builds on 22/24 and runs the Node 20 leg against the committed dist. docs-deploy reconciliation is descoped (deploy-docs.sh is the only path that bumps docs before deploy; needs a release-ordering fix first). Removed devDeps: rollup, @rollup/plugin-babel, @rollup/plugin-node-resolve, @rollup/plugin-replace, @babel/core, @babel/preset-typescript, terser, rollup-plugin-dts. Added: tsdown.
1 parent 50f6b24 commit 7c6af4e

30 files changed

Lines changed: 8714 additions & 11436 deletions

.github/workflows/nodejs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node }}
2828
- run: npm install --prefer-offline --no-audit --no-fund
29+
# The build tool (tsdown) requires Node >= 22.18. The published library and
30+
# its tests still run on Node 20: that leg tests the committed dist rather
31+
# than rebuilding. Node 22/24 rebuild from source before testing.
2932
- run: npm run build
33+
if: matrix.node != '20'
3034
- run: npm run test

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
22

DEVELOPERS.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
## <a name="setup"></a> Setup
99

10+
Building and releasing require **Node >= 22.18** (the bundler, [tsdown](https://tsdown.dev), needs it); `nvm use` picks up the pinned `.nvmrc`. The published library runs on far older Node, and the CI test matrix still includes Node 20.
11+
1012
```shell
1113
npm install
1214
```
@@ -19,8 +21,7 @@ npm install
1921
| `npm test` | Run the test suite (vitest) |
2022
| `npm run typecheck` | Type-check the source without emitting |
2123
| `npm run lint` | Lint source and tests (eslint) |
22-
| `npm run dev` | Watch mode for ESM dev build |
23-
| `npm run dev:cjs` | Watch mode for CJS dev build |
24+
| `npm run dev` | Watch mode (rebuilds all dist targets via tsdown) |
2425
| `npm run bench` | Build, then run the core search + index regression benchmarks |
2526
| `npm run bench:search` | Search benchmark (object/string fuzzy, scaling, remove) |
2627
| `npm run bench:index` | Index creation benchmark across dataset sizes |
@@ -30,7 +31,7 @@ npm install
3031

3132
## <a name="structure"></a> Project Structure
3233

33-
Source is TypeScript. Types are emitted from source via `rollup-plugin-dts`.
34+
Source is TypeScript. The build, including `.d.ts` emit, runs through [tsdown](https://tsdown.dev) (rolldown engine); see `tsdown.config.ts`.
3435

3536
```
3637
src/
@@ -42,7 +43,8 @@ src/
4243
entry.ts — Entry point with static methods and type exports
4344
test/ — Tests and fixtures
4445
bench/ — Benchmarks (search, index creation, extended, tokens, workers)
45-
scripts/ — Rollup build configs
46+
tsdown.config.ts — Build config (all dist targets + types)
47+
scripts/ — Release + docs helpers (bump-docs, deploy-docs, release)
4648
dist/ — Built output (CJS, ESM, .d.ts)
4749
```
4850

0 commit comments

Comments
 (0)