-
-
Notifications
You must be signed in to change notification settings - Fork 648
Description
Describe the bug
When trying to use @blocknote/xl-ai in a Next.js 15.5.5 project (React 19 + Turbopack), the build fails with the following error:
Export default doesn't exist in target module
./node_modules/.pnpm/@ai-sdk+react@2.0.70_react@19.1.0_zod@4.1.12/node_modules/@ai-sdk/react/dist/index.mjs:338:1
Export default doesn't exist in target module
336 | } from "ai";
337 | import { useCallback as useCallback3, useId as useId2, useRef as useRef3, useState as useState2 } from "react";
> 338 | import useSWR2 from "swr";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
The error continues with:
The export default was not found in module node_modules/swr/dist/index/react-server.mjs [app-rsc].
Did you mean to import unstable_serialize?
This breaks the build and prevents using the @blocknote/xl-ai module.
It seems that @ai-sdk/react (a dependency of @blocknote/xl-ai) is still importing SWR as a default export:
import useSWR from "swr";but in swr@2.3.6 (and later), there is no default export, only named exports.
This causes the build to fail under ESM + Turbopack (Next.js 15).
To Reproduce
-
Create a new Next.js 15 project (React 19, Turbopack enabled).
-
Install dependencies:
pnpm add @blocknote/core @blocknote/mantine @blocknote/react @blocknote/xl-ai ai
-
Use the following code in
app/editor/page.tsx:
(your provided code here) -
Run
pnpm run buildornext build.
Result:
Build fails with:
Export default doesn't exist in target module (swr)
Misc
- Node version: 22
- Package manager: pnpm
- Browser: Firefox and Edge
Notes / Possible Fix
-
Likely cause:
@ai-sdk/reactimportsuseSWRas a default export, butswr@2.xonly provides named exports. -
Possible workaround: lock SWR to version
^1.3.0. -
A long-term fix would be updating
@ai-sdk/reactto use:import { useSWR } from "swr";
-
The problem only appears with Next.js 15 + React 19 + Turbopack (ESM) builds.
