Skip to content

Commit e61377c

Browse files
authored
feat(nextjs): Add use client directive to client SDK entrypoints (#15575)
Fixes #10366
1 parent 0a7aabd commit e61377c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/nextjs/rollup.npm.config.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ export default [
1818
// the name doesn't match an SDK dependency)
1919
packageSpecificConfig: {
2020
external: ['next/router', 'next/constants', 'next/headers', 'stacktrace-parser'],
21+
22+
// Next.js and our users are more happy when our client code has the "use client" directive
23+
plugins: [
24+
{
25+
name: 'sentry-internal-add-use-client-directive-to-client-entry-points-plugin-extravaganza',
26+
banner: chunk => {
27+
if (
28+
chunk.isEntry &&
29+
(chunk.facadeModuleId.endsWith('/src/index.client.ts') ||
30+
chunk.facadeModuleId.endsWith('/src/client/index.ts'))
31+
) {
32+
return '"use client";';
33+
}
34+
},
35+
},
36+
],
2137
},
2238
}),
2339
),

0 commit comments

Comments
 (0)