Skip to content

Commit 5ccdf44

Browse files
Fix "Warning: useLayoutEffect does nothing on the server" (#52)
Don't bundle @lit/react in ESM build
1 parent e471e4a commit 5ccdf44

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

package-lock.json

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
> - 🏠 Internal
1111
> - 💅 Polish
1212
13+
## Unreleased
14+
15+
- 🐛 Fix "Warning: useLayoutEffect does nothing on the server" when using `@theoplayer/react-ui` in Node. ([#52](https://github.com/THEOplayer/web-ui/pull/52))
16+
1317
## v1.7.0 (2024-02-15)
1418

1519
- 🚀 Added support for loading in Node for static site generation (SSG) or server-side rendering (SSR). ([#50](https://github.com/THEOplayer/web-ui/pull/50))

react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"directory": "react"
5050
},
5151
"dependencies": {
52-
"@lit/react": "^1.0.2",
52+
"@lit/react": "^1.0.3",
5353
"@theoplayer/web-ui": "^1.7.0"
5454
},
5555
"peerDependencies": {

react/rollup.config.mjs

+11-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ const banner = `/*!
1717
* THEOplayer Open Video UI for React (v${version})
1818
* License: ${license}
1919
*/`;
20-
const externals = {
20+
const globals = {
2121
react: 'React',
2222
'@theoplayer/web-ui': 'THEOplayerUI',
2323
'@theoplayer/web-ui/es5': 'THEOplayerUI'
2424
};
25+
const external = Object.keys(globals);
26+
const esmExternal = [
27+
...external,
28+
// @lit-react has a separate entry point for Node, to support SSR.
29+
// Don't bundle it ourselves, otherwise we'll always ship the browser version.
30+
'@lit/react'
31+
];
2532

2633
/**
2734
* @param {{configOutputDir?: string}} cliArgs
@@ -60,10 +67,10 @@ function jsConfig(outputDir, { es5 = false, production = false, sourcemap = fals
6067
sourcemap,
6168
indent: false,
6269
banner,
63-
globals: externals
70+
globals
6471
},
6572
context: 'self',
66-
external: Object.keys(externals),
73+
external,
6774
plugins: jsPlugins({ es5, module: false, production, sourcemap })
6875
},
6976
{
@@ -75,7 +82,7 @@ function jsConfig(outputDir, { es5 = false, production = false, sourcemap = fals
7582
indent: false
7683
},
7784
context: 'self',
78-
external: Object.keys(externals),
85+
external: esmExternal,
7986
plugins: jsPlugins({ es5, module: true, production, sourcemap })
8087
}
8188
]);

0 commit comments

Comments
 (0)