Commit c99daf6
chore: migrate build toolchain from npm/tsc/ncc/Jest to Bun (#189)
Replace the previous Node.js-based build toolchain with Bun,
consolidating TypeScript compilation, bundling, and testing
into a single modern runtime.
This migration was informed by official Bun documentation
(bun.sh/docs) and current best practices for 2025.
## Build System Changes
**Previous approach:**
Two-step build process using TypeScript compiler (`tsc`)
followed by Vercel's `ncc` bundler,
producing a 1.2MB bundle with sourcemap-register.js
and licenses.txt as separate artifacts.
**New approach:**
Single-command build using `bun build` with integrated bundling,
minification, and source map generation.
Output is 50% smaller (607KB vs 1.2MB)
and requires no separate bundling step.
Build command configuration based on Bun's bundler documentation
(bun.sh/docs/bundler) specifying `--target=node` for Node.js
compatibility and `--format=cjs` for CommonJS output required
by GitHub Actions' node20 runtime.
## Test System Changes
Replaced Jest and ts-jest with Bun's native test runner.
Bun automatically rewrites `@jest/globals` imports
to use equivalent `bun:test` APIs,
allowing tests to run without modification.
This compatibility documented at bun.sh/guides/test/migrate-from-jest.
Test execution is significantly faster
(26ms vs previous Jest execution times)
due to Bun's optimized runtime.
## Linting Configuration
Migrated ESLint from legacy `.eslintrc.json` to flat config
(`eslint.config.js`) following ESLint v9 migration guide.
Flat config is the recommended format as of 2025
and provides better compatibility with ES modules.
Added special rule overrides for test files
to disable `@typescript-eslint/require-await`
and `@typescript-eslint/no-unused-vars`,
which are incompatible with Jest-style mock patterns
that Bun's test runner supports for compatibility.
## Dependencies Removed
- `jest` and `ts-jest`: Replaced by Bun's built-in test runner
- `@vercel/ncc`: Replaced by Bun's bundler
- `typescript`: Bun includes native TypeScript support
- `@types/node`: Bun includes Node.js type definitions
Total reduction: 5 development dependencies removed.
## Configuration Changes
**package.json:**
- Added `"type": "module"` for ES module support
(required by ESLint flat config)
- Updated `main` from `lib/main.js` to `dist/index.js`
- Rewrote all npm scripts to use Bun commands
- Removed `package` script (merged into `build`)
**tsconfig.json:**
- Changed from `exclude` to explicit `include` pattern
to ensure test files are included for ESLint type checking
- Added `dist` and `lib` to exclude list
**GitHub Actions:**
- Replaced `setup-node` with `mise-action`
to ensure CI uses same Bun version as local development
(version managed via mise.toml)
- Changed `npm install` to `bun install --frozen-lockfile`
- Updated all build/lint/test commands to use Bun
**action.yml:**
- Updated runtime from `node16` to `node20`
following GitHub Actions best practices for 2025
## Code Fixes
**src/input.ts:**
Fixed `@typescript-eslint/no-unsafe-enum-comparison` errors
by explicitly casting string to enum type
before comparison (lines 65, 77).
Changed `InputOptions` export to type-only export
for ES module compatibility.
**src/main.ts:**
Fixed `@typescript-eslint/no-floating-promises` error
by marking `main()` call with `void` operator (line 67).
**__tests__/output.test.ts:**
Fixed `prefer-const` error by changing mutable `let`
to immutable `const` for test object (line 22).
## Information Sources
Migration decisions based on:
- Official Bun documentation (bun.sh/docs)
- Bun bundler guide (bun.sh/docs/bundler)
- Jest migration guide (bun.sh/guides/test/migrate-from-jest)
- ESLint v9 migration guide
(eslint.org/docs/latest/use/configure/migration-guide)
- GitHub Actions node20 best practices
- Package manager comparison research (2025 resources)
## Verification
All critical commands verified:
- `bun run build`: Produces 607KB minified bundle with source maps
- `bun run lint`: Passes with 0 errors/warnings
- `bun test`: All 20 tests pass in 26ms
## AI assistance
This change was entirely carried out by an LLM
with human instruction on the goal and verification criteria.
Co-authored-by: Claude <noreply@anthropic.com>1 parent c21d236 commit c99daf6
File tree
20 files changed
+1009
-43527
lines changed- .changes/unreleased
- .github/workflows
- __tests__
- dist
- src
20 files changed
+1009
-43527
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
| |||
53 | 50 | | |
54 | 51 | | |
55 | 52 | | |
56 | | - | |
| 53 | + | |
57 | 54 | | |
58 | 55 | | |
59 | | - | |
| 56 | + | |
60 | 57 | | |
61 | 58 | | |
62 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments