Skip to content
Source
Sign inSign up
TanStack/ai

ai-claude-code and ai-sandbox: add "sideEffects": false so translateSdkStream tree-shakes #2032

Send to my agent
Closedadelrodriguez(GitHub profile, opens in a new tab) opened this issue 0 comments

TanStack AI version

@tanstack/ai-claude-code 1.0.1, @tanstack/ai-sandbox 1.1.0 (@tanstack/ai 1.1.0)

Framework/Library version

Vite 8.0.0 (Rolldown), TanStack Start 1.169, Nitro 3

Describe the bug and the steps to reproduce it

@tanstack/ai and @tanstack/ai-skills set "sideEffects": false in package.json. @tanstack/ai-claude-code and @tanstack/ai-sandbox do not. So a bundler must keep every module that the root entry of @tanstack/ai-claude-code imports, also when the app uses only translateSdkStream.

  1. Import only the translator in a server module:
    import { translateSdkStream } from "@tanstack/ai-claude-code"
  2. Build with Vite 8 (Rolldown).
  3. The server output keeps side-effect imports of @modelcontextprotocol/sdk (types.js plus ajv, about 475 kB) and of hono with @hono/node-server (about 27 kB). They come from @tanstack/ai-sandbox/dist/esm/tool-bridge.js through the root entry of @tanstack/ai-claude-code. No sandbox code is called.

With this Rolldown rule, both imports go away and the build still works:

build: {
  rolldownOptions: {
    treeshake: {
      moduleSideEffects: [
        { test: /\/@tanstack\/ai-(claude-code|sandbox)\//, sideEffects: false },
      ],
    },
  },
},

Expected: "sideEffects": false in both packages, as in @tanstack/ai. A subpath export for the translator, such as @tanstack/ai-claude-code/translate, would also let an app that only translates stream-json skip the required @tanstack/ai-sandbox peer.

The steps above. The rule shows the fix.

  1. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

  2. tombeckenham linked this to #2106

  3. AlemTuzlak closed this

Sign in to join this conversation.