Skip to content

build: drop Node from Docker, patch @volar/typescript for Bun#199

Merged
kernoeb merged 1 commit into
mainfrom
drop-node-bun-volar-patch
May 25, 2026
Merged

build: drop Node from Docker, patch @volar/typescript for Bun#199
kernoeb merged 1 commit into
mainfrom
drop-node-bun-volar-patch

Conversation

@kernoeb

@kernoeb kernoeb commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Drops Node 24 from the build stage of Dockerfile (was only there for vue-tsc)
  • Adds a bun patch on @volar/typescript@2.4.28 to fix the long-standing incompat where Bun's module loader does not honor fs.readFileSync monkey-patching — the trick Volar uses to inject .vue extension support into TypeScript (Bun issue 4754, opened 2023).
  • The patch replaces the monkey-patch with a direct Module#_compile call, honored by both Node and Bun. Same fix lives on a fork at kernoeb/volar.js@fix-bun-vue-tsc.

What the patch does

Before After
Monkey-patches fs.readFileSync to intercept Node's CJS loader read of tsc.js Reads tsc.js directly, transforms it, then Module#_compiles the result
Uses a thrown transformTscContent failure as the "this is the v5.7+ shim" signal Detects the shim with a regex up front; real transform failures now surface their real error
No BOM strip (relied on Node's Module._extensions['.js'] wrapper) Explicitly strips UTF-8 BOM before compiling
No compile cache (the v5.7+ tsc shim called enableCompileCache(), our patch bypassed it) Calls Module.enableCompileCache() to mirror the shim

Test plan

  • docker build --target build passes end-to-end in ~44s (was building successfully with Node previously)
  • bun install re-applies the patch automatically (verified on clean rm -rf node_modules && bun install)
  • bun run typecheck (= vue-tsc -b --force) exits 0
  • bun run test:unit — 136 tests, 5704 expect() calls, all green
  • Production image runs and serves /api/ping as before (smoke-test on test server)

Notes

  • @volar/typescript 2.4.28 is the version currently pinned via bun.lock. If volar bumps minor we'll need to regenerate the patch — bun patch will fail-loud on hash mismatch.
  • The fork is not yet a PR upstream — we keep the local patch until Volar merges it.

vue-tsc was the only thing keeping Node in the runtime image. With the
upstream Bun-compat patch on @volar/typescript applied via `bun patch`,
the build now runs entirely on Bun.

Patch reference: https://github.com/kernoeb/volar.js/tree/fix-bun-vue-tsc
Upstream issue: oven-sh/bun#4754
@kernoeb kernoeb enabled auto-merge (squash) May 25, 2026 12:50
@kernoeb kernoeb merged commit 3c17a21 into main May 25, 2026
9 checks passed
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