Skip to content

Commit

Permalink
Fix "Warning: useLayoutEffect does nothing on the server" (#52)
Browse files Browse the repository at this point in the history
Don't bundle @lit/react in ESM build
  • Loading branch information
MattiasBuelens authored Feb 15, 2024
1 parent e471e4a commit 5ccdf44
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
> - 🏠 Internal
> - 💅 Polish
## Unreleased

- 🐛 Fix "Warning: useLayoutEffect does nothing on the server" when using `@theoplayer/react-ui` in Node. ([#52](https://github.com/THEOplayer/web-ui/pull/52))

## v1.7.0 (2024-02-15)

- 🚀 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))
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"directory": "react"
},
"dependencies": {
"@lit/react": "^1.0.2",
"@lit/react": "^1.0.3",
"@theoplayer/web-ui": "^1.7.0"
},
"peerDependencies": {
Expand Down
15 changes: 11 additions & 4 deletions react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ const banner = `/*!
* THEOplayer Open Video UI for React (v${version})
* License: ${license}
*/`;
const externals = {
const globals = {
react: 'React',
'@theoplayer/web-ui': 'THEOplayerUI',
'@theoplayer/web-ui/es5': 'THEOplayerUI'
};
const external = Object.keys(globals);
const esmExternal = [
...external,
// @lit-react has a separate entry point for Node, to support SSR.
// Don't bundle it ourselves, otherwise we'll always ship the browser version.
'@lit/react'
];

/**
* @param {{configOutputDir?: string}} cliArgs
Expand Down Expand Up @@ -60,10 +67,10 @@ function jsConfig(outputDir, { es5 = false, production = false, sourcemap = fals
sourcemap,
indent: false,
banner,
globals: externals
globals
},
context: 'self',
external: Object.keys(externals),
external,
plugins: jsPlugins({ es5, module: false, production, sourcemap })
},
{
Expand All @@ -75,7 +82,7 @@ function jsConfig(outputDir, { es5 = false, production = false, sourcemap = fals
indent: false
},
context: 'self',
external: Object.keys(externals),
external: esmExternal,
plugins: jsPlugins({ es5, module: true, production, sourcemap })
}
]);
Expand Down

0 comments on commit 5ccdf44

Please sign in to comment.