Skip to content

@tanstack/ai-code-mode should not depend on esbuild (Node.js-only, breaks Cloudflare/edge bundlers) #487

@husayt

Description

@husayt

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:

  1. Browser bundle: esbuild is a Node.js native binary — it must be stubbed/aliased out to prevent the browser build from failing.
  2. 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

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions