TanStack AI version
0.1.4
Framework/Library version
@tanstack/ai-code-mode
Describe the bug and the steps to reproduce it
Problem
@tanstack/ai-code-mode imports esbuild (specifically transform/stripTypeScript) at the module level. This causes two issues for edge/Cloudflare Workers deployments:
- Browser bundle: esbuild is a Node.js native binary — it must be stubbed/aliased out to prevent the browser build from failing.
- Server bundle (Cloudflare Pages / Workers): esbuild 0.25+ added Yarn PnP detection via
require("pnpapi") in its main.js. Cloudflare's bundler cannot resolve this module and does not allow externals, causing:
ERROR: Cannot resolve "pnpapi" from "…/esbuild/lib/main.js" and externals are not allowed!
Workarounds required today
- Vite alias to a no-op stub:
esbuild → esbuild-browser-stub.ts
- Custom Nitro Rollup plugin to stub
pnpapi as a virtual module
Suggested fix
Replace the esbuild dependency with a lightweight, pure-JS TypeScript stripper such as:
Environment
@tanstack/ai-code-mode: (check your version)
esbuild: 0.25.12
- Deploy target: Cloudflare Pages (Nitro)
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
TanStack AI version
0.1.4
Framework/Library version
@tanstack/ai-code-mode
Describe the bug and the steps to reproduce it
Problem
@tanstack/ai-code-modeimportsesbuild(specificallytransform/stripTypeScript) at the module level. This causes two issues for edge/Cloudflare Workers deployments:require("pnpapi")in itsmain.js. Cloudflare's bundler cannot resolve this module and does not allow externals, causing:Workarounds required today
esbuild → esbuild-browser-stub.tspnpapias a virtual moduleSuggested fix
Replace the esbuild dependency with a lightweight, pure-JS TypeScript stripper such as:
oxc-transform— Rust/WASM, edge-compatible@babel/plugin-transform-typescriptEnvironment
@tanstack/ai-code-mode: (check your version)esbuild: 0.25.12Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct