Link to the code that reproduces this issue
https://github.com/ceolinwill/nextjs-pnpm-sourcemap-error
To Reproduce
- Start a new nextjs app using pnpm workspaces
- Add the
workflow library
- Create a workflow using the AI SDK
- Run
pnpm build
Or:
- Clone this repo
- Run
pnpm build
Current vs. Expected behavior
Current behavior
The build succeeds, but Next logs source-map errors:
ERROR failed to read input source map: failed to find input source map file "index.js.map" in "node_modules/.pnpm/@ai-sdk+provider-utils@5.0.1_zod@4.4.3/node_modules/@ai-sdk/provider-utils/dist/index.js" file as either "node_modules/.pnpm/@ai-sdk+provider-utils@5.0.1_zod@4.4.3/node_modules/@ai-sdk/provider-utils/dist/index.js.map" or with appended .map
at crates/swc/src/lib.rs:398
ERROR failed to read input source map: failed to find input source map file "index.js.map" in "node_modules/.pnpm/@workflow+serde@4.1.0/node_modules/@workflow/serde/dist/index.js" file as either "node_modules/.pnpm/@workflow+serde@4.1.0/node_modules/@workflow/serde/dist/index.js.map" or with appended .map
at crates/swc/src/lib.rs:398
The referenced map files do exist:
test -f node_modules/.pnpm/@ai-sdk+provider-utils@5.0.1_zod@4.4.3/node_modules/@ai-sdk/provider-utils/dist/index.js.map
test -f node_modules/.pnpm/@workflow+serde@4.1.0/node_modules/@workflow/serde/dist/index.js.map
Expected behavior
Next should not log source-map read errors when the dependency source map files exist.
Additional context
This reproduces in a pnpm workspace with a Next app under apps/web.
It looks like the source-map path is being resolved relative to the app directory, while pnpm’s virtual store is at the workspace root.
The error appears when workflow/next compiles a workflow step that imports AI SDK packages. A plain Next app importing AI SDK did not reproduce it.
However, I only noticed this issue when I upgraded to the AI SDK v7. It wasn't happening on v6.
Related issues:
Link to the code that reproduces this issue
https://github.com/ceolinwill/nextjs-pnpm-sourcemap-error
To Reproduce
workflowlibrarypnpm buildOr:
pnpm buildCurrent vs. Expected behavior
Current behavior
The build succeeds, but Next logs source-map errors:
The referenced map files do exist:
Expected behavior
Next should not log source-map read errors when the dependency source map files exist.
Additional context
This reproduces in a pnpm workspace with a Next app under apps/web.
It looks like the source-map path is being resolved relative to the app directory, while pnpm’s virtual store is at the workspace root.
The error appears when workflow/next compiles a workflow step that imports AI SDK packages. A plain Next app importing AI SDK did not reproduce it.
However, I only noticed this issue when I upgraded to the AI SDK v7. It wasn't happening on v6.
Related issues: