Writing

Performance · 3 min read

How I Moved This Blog from Node.js to Bun

The package manager was the easy part. File APIs, CI, compatibility checks, and Claude Code produced most of the migration's useful work.

In this article5 sections

Moving this blog to Bun shortened startup and builds. Most of the migration work went into file operations, CI, and checking which Node assumptions still held.

Part 1 covers why I switched. This post covers the migration.

Looking back This describes the April 2025 migration. As of November 2026, this site uses Astro, Node.js, and pnpm. The commands and timings below document the earlier setup.

Start with the Smallest Change

I started with the scripts in package.json:

 "scripts": {
-  "start": "ts-node src/index.ts",
-  "build": "tsc",
-  "dev": "nodemon --watch src --exec ts-node src/index.ts",
+  "start": "bun src/index.ts",
+  "build": "bun build ./src/index.ts --outdir ./dist --target=bun",
+  "dev": "bun --watch src/index.ts",
 }

Bun runs TypeScript directly, so I could remove the separate compile step. Its bundler also replaced the build configuration I had accumulated around TypeScript.

Then I moved CI:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: oven-sh/setup-bun@v1
        with:
          bun-version: 1.2.11
      - run: bun install
      - run: bun run build
      - run: bun run typecheck

That replaced a 4,500-line package-lock.json with bun.lock.

The File APIs Were the Real Migration

The biggest payoff came from converting Node’s fs operations to Bun’s native File API.

I used Claude Code to find the file-system calls and review them one at a time:

  1. Scan for patterns like fs.readFile and fs.pathExists across the codebase
  2. Group the results by how each file was used
  3. Compare the Node and Bun versions side by side
  4. Apply and test each change separately

It also suggested arrayBuffer() for binary operations, which I probably wouldn’t have reached for on my own.

What Didn’t Transfer Cleanly

Not every Node package worked with Bun. Documentation was thinner, and Bun’s errors sometimes gave me less to work with than Node’s. Native C and C++ extensions were the biggest compatibility risk.

Test the dependencies that matter Don’t assume Node compatibility means your production path works. Check native extensions and the code behind your critical requests before changing runtimes.

The Result

Startup improved more in percentage terms. Figure 1 shows why the build change saved more time.

Figure 1The build step saved more secondsGap labels show seconds saved. The common zero-based scale makes the larger build saving visible; exact values and relative changes stay in the table.
Static paired comparison. Gap labels show the difference; all exact values are in the accompanying table.0.9 s saved17 s saved
Static paired comparison. Gap labels show the difference; all exact values are in the accompanying table.0.9 s saved17 s saved
Node.jsBun
Exact comparison values; change is relative to Node.js.
StageNode.js (s)Bun (s)Change
Startup1.20.3-75.0%0.9 s saved
Build37.020.0-45.9%17 s saved

Tap a point or use arrow keys to inspect values.

The 2025 article's recorded local build-tool observations, not serverless request timings or a current runtime benchmark. Hardware, repetitions and distributions were not published. No new measurements were run for this chart.

The build saved 17 seconds per run; startup saved 0.9 seconds. The dependency count also fell from 20+ to 15. I ended up with fewer configuration files and more direct file-system code. That matters more to me than winning a runtime benchmark.

How I Would Do It Again

I wouldn’t migrate everything in one pass. The order that worked was:

  1. Package management and simple scripts
  2. Build configuration
  3. CI
  4. File operations
  5. Dependency cleanup

That order kept each failure small enough to understand. For this I/O-heavy codebase, shorter builds and less file-handling code made the migration worthwhile. I didn’t need to keep Node just because the project started there.

Was this useful?

What was missing?

Thanks for the feedback.