Skip to content

Commit bf3ac79

Browse files
authored
fix: Fix jest usage with mocks (#3691)
1 parent 4296d32 commit bf3ac79

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

.changeset/fix-mock-cjs-exports.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@data-client/core": patch
3+
"@data-client/react": patch
4+
---
5+
6+
Fix CommonJS compatibility for `/mock` subpath exports.
7+
8+
Jest and other CommonJS consumers can now import from `@data-client/react/mock` and `@data-client/core/mock` without ESM parsing errors.

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
},
5757
"./mock": {
5858
"types": "./lib/mock/index.d.ts",
59+
"require": "./dist/mock.js",
5960
"default": "./lib/mock/index.js"
6061
},
6162
"./package.json": "./package.json"

packages/core/rollup.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
5858
[
5959
{ input: 'src/index.ts', output: pkg.main },
6060
{ input: 'src/next/index.ts', output: 'dist/next.js' },
61+
{ input: 'src/mock/index.ts', output: 'dist/mock.js' },
6162
].forEach(({ input, output }) => {
6263
configs.push({
6364
input,

packages/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
},
141141
"./mock": {
142142
"types": "./lib/mock/index.d.ts",
143+
"require": "./dist/mock.js",
143144
"default": "./lib/mock/index.js"
144145
},
145146
"./package.json": "./package.json"

packages/react/rollup.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
9999
input: 'src/server/redux/index.ts',
100100
output: 'dist/server/redux/index.js',
101101
},
102+
{ input: 'src/mock/index.ts', output: 'dist/mock.js' },
102103
].forEach(({ input, output }) => {
103104
configs.push({
104105
input,

0 commit comments

Comments
 (0)