Skip to content

Commit 43403dc

Browse files
authored
fix(nextjs): Remove ai from default server external packages (#16736)
We have added the 'ai' package to our list of externalized packages for instrumentation purposes. Unfortunately this causes Next.js to incorrectly evaluate the Vercel AI SDK's conditional exports - specifically the `react-server` export condition isn't properly handled when the package is externalized, resulting in client-side code being loaded in server components instead of the server-side functions.
1 parent 2c4cb5c commit 43403dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ let showedExperimentalBuildModeWarning = false;
2020
// Packages we auto-instrument need to be external for instrumentation to work
2121
// Next.js externalizes some packages by default, see: https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages
2222
// Others we need to add ourselves
23+
//
24+
// NOTE: 'ai' (Vercel AI SDK) is intentionally NOT included in this list.
25+
// When externalized, Next.js doesn't properly handle the package's conditional exports,
26+
// specifically the "react-server" export condition. This causes client-side code to be
27+
// loaded in server components instead of the appropriate server-side functions.
2328
export const DEFAULT_SERVER_EXTERNAL_PACKAGES = [
24-
'ai',
2529
'amqplib',
2630
'connect',
2731
'dataloader',

0 commit comments

Comments
 (0)