Skip to content

Commit

Permalink
fix: Commonjs builds use only one context instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Jun 14, 2024
1 parent f4ca16c commit 233f400
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/strong-bats-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@data-client/react': patch
---

Fix commonjs builds to keep same context instance

There must be only one instance of a context, so we need to ensure our new entrypoints don't include createContext
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@
},
"./ssr": {
"types": "./lib/server/index.d.ts",
"require": "./dist/ssr.js",
"require": "./dist/server/index.js",
"default": "./lib/server/index.js"
},
"./redux": {
"types": "./lib/server/redux/index.d.ts",
"require": "./dist/redux.js",
"require": "./dist/server/redux/index.js",
"default": "./lib/server/redux/index.js"
},
"./package.json": "./package.json"
Expand Down
13 changes: 10 additions & 3 deletions packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const nativeExtensions = ['.native.ts', ...extensions];
process.env.NODE_ENV = 'production';

function isExternal(id) {
return dependencies.some(dep => dep === id || id.startsWith(dep));
return (
// when we import contexts in our other entry points
id === '../../index.js' ||
dependencies.some(dep => dep === id || id.startsWith(dep))
);
}

const configs = [];
Expand Down Expand Up @@ -77,8 +81,11 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
[
{ input: 'lib/index.js', output: pkg.main },
{ input: 'lib/next/index.js', output: 'dist/next.js' },
{ input: 'lib/server/index.js', output: 'dist/ssr.js' },
{ input: 'lib/server/redux/index.js', output: 'dist/redux.js' },
{ input: 'lib/server/index.js', output: 'dist/server/index.js' },
{
input: 'lib/server/redux/index.js',
output: 'dist/server/redux/index.js',
},
].forEach(({ input, output }) => {
configs.push({
input,
Expand Down

0 comments on commit 233f400

Please sign in to comment.