Skip to content

Commit

Permalink
ignore module-level directive warnings about "use client"; (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
eritbh authored Oct 10, 2024
1 parent 1ac5a56 commit 3d4046f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ export default ['chrome', 'firefox'].flatMap(platform => [
],
}),
],
// When bundling a bunch of modules together, directives in each module
// end up not really working because the output is just one module and
// the build doesn't know what to do. Some React libraries have started
// including "use client" directives to indicate to certain build
// systems that the code in those modules isn't meant to be run as part
// of server-side rendering. We don't care about any of that (we're a
// browser extension, we *only* have client-side code) and the directive
// has no meaning at runtime so we just ignore Rollup's warnings there
onwarn (warning, defaultHandler) {
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE'
&& warning.message.includes('use client')
) {
return;
}
defaultHandler(warning);
},
},
{
input: 'extension/data/background/index.ts',
Expand Down

0 comments on commit 3d4046f

Please sign in to comment.