Skip to content

Commit a0e1c20

Browse files
committed
fix: add 'use client' directive into tooltip dist files to prevent next.js 13 app break
1 parent 9237e9e commit a0e1c20

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

rollup.config.prod.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ const input = ['src/index.tsx']
1313

1414
const name = 'ReactTooltip'
1515

16+
const banner = `
17+
/*
18+
* React Tooltip
19+
* {@link https://github.com/ReactTooltip/react-tooltip}
20+
* @copyright ReactTooltip Team
21+
* @license MIT
22+
*/
23+
24+
'use client';` // this 'use client' prevent break Next.js 13 projects when using tooltip on server side components
25+
1626
const external = [
1727
...Object.keys(pkg.peerDependencies ?? {}),
1828
...Object.keys(pkg.dependencies ?? {}),
@@ -79,7 +89,7 @@ const minifiedBuildFormats = buildFormats.map(({ file, extractCSS, ...rest }) =>
7989
...rest,
8090
minify: true,
8191
extractCSS,
82-
plugins: [terser(), filesize()],
92+
plugins: [terser({ compress: { directives: false } }), filesize()],
8393
}))
8494

8595
const allBuildFormats = [...buildFormats, ...minifiedBuildFormats]
@@ -111,6 +121,7 @@ const config = allBuildFormats.map(
111121
name,
112122
globals,
113123
sourcemap: true,
124+
banner,
114125
},
115126
external,
116127
plugins,

0 commit comments

Comments
 (0)