Skip to content

Commit 3fabd41

Browse files
authored
fix: ESM compliant bundling (#3521)
* fix various bundling issues * add package.json to exports * remove @svgr/rollup * remove node v12 from CI * support devtools/development * do not alias react-query * add side effect * remove "module" * fix * fix exports * add "module" * update @babel/runtime * don't preserve modules * switch back to babel * add migration note * update babel * update rollup * downgrade @rollup/plugin-commonjs
1 parent 1af25c6 commit 3fabd41

File tree

31 files changed

+427
-1326
lines changed

31 files changed

+427
-1326
lines changed

.babelrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { NODE_ENV, BABEL_ENV } = process.env
22
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3+
const es = BABEL_ENV === 'es'
34
const loose = true
45

56
module.exports = {
@@ -20,10 +21,11 @@ module.exports = {
2021
],
2122
plugins: [
2223
cjs && ['@babel/transform-modules-commonjs', { loose }],
23-
[
24+
es && ['babel-plugin-add-import-extension', { extension: 'mjs' }],
25+
// no runtime for umd builds
26+
BABEL_ENV && [
2427
'@babel/transform-runtime',
2528
{
26-
useESModules: !cjs,
2729
version: require('./package.json').dependencies[
2830
'@babel/runtime'
2931
].replace(/^[^0-9]*/, ''),

.github/workflows/test-and-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
node: [12, 14, 16]
20+
node: [14, 16]
2121
react: [17, 18]
2222
steps:
2323
- uses: actions/checkout@v2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../lib/broadcastQueryClient-experimental'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../lib/broadcastQueryClient-experimental/index')

core/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../lib/core'

core/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../lib/core/index')

core/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../lib/createAsyncStoragePersister'

createAsyncStoragePersister/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../lib/createAsyncStoragePersister/index')

createAsyncStoragePersister/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)