Skip to content

Commit 44cdc09

Browse files
authored
Fix externals (#108)
* Externalize more react stuff * Changeset * Updates to other vite.config.js files
1 parent e93bc51 commit 44cdc09

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎.changeset/heavy-horses-prove.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"use-coordination": patch
3+
---
4+
5+
Fix externalization of react and react-dom.

‎packages/main/dev/vite.config.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ export default defineConfig({
2121
formats: ['es', 'umd'],
2222
},
2323
rollupOptions: {
24-
external: ['react', 'react-dom'],
24+
external: (id) => (
25+
id === 'react'
26+
|| id === 'react-dom'
27+
|| id.startsWith('react/')
28+
|| id.startsWith('react-dom/')
29+
),
2530
output: {
2631
globals: {
2732
react: 'React',
@@ -34,4 +39,4 @@ export default defineConfig({
3439
'process.env.NODE_ENV': `"${process.env.APP_ENV}"`,
3540
},
3641
plugins: [react()]
37-
});
42+
});

‎packages/main/prod/vite.config.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ export default defineConfig({
2222
formats: ['es', 'umd'],
2323
},
2424
rollupOptions: {
25-
external: ['react', 'react-dom'],
25+
external: (id) => (
26+
id === 'react'
27+
|| id === 'react-dom'
28+
|| id.startsWith('react/')
29+
|| id.startsWith('react-dom/')
30+
),
2631
output: {
2732
globals: {
2833
react: 'React',
@@ -38,4 +43,4 @@ export default defineConfig({
3843
react(),
3944
visualizer(),
4045
],
41-
});
46+
});

‎scripts/vite.config.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ export default defineConfig({
3333
formats: ['es'],
3434
},
3535
rollupOptions: {
36-
external: ['react', 'react-dom', ...moreExternals],
36+
// Externalize react (including subpath imports like react/jsx-runtime)
37+
external: (id) => (
38+
id === 'react'
39+
|| id === 'react-dom'
40+
|| id.startsWith('react/')
41+
|| id.startsWith('react-dom/')
42+
|| moreExternals.includes(id)
43+
),
3744
output: {
3845
globals: {
3946
react: 'React',
@@ -55,4 +62,4 @@ export default defineConfig({
5562
include: /src\/.*\.[tj]sx?$/,
5663
exclude: [],
5764
},
58-
});
65+
});

0 commit comments

Comments
 (0)