Skip to content

Commit 24535bc

Browse files
chore: fix ssr in rr7.3
1 parent 3bdd69e commit 24535bc

File tree

4 files changed

+68
-8
lines changed

4 files changed

+68
-8
lines changed

examples/federation/epic-stack-remote/rsbuild.config.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export default defineConfig({
4848
devtool: false,
4949
}
5050
},
51+
resolve: {
52+
dedupe: ['react', 'react-dom'],
53+
},
5154
environments: {
5255
web: {
5356
source: {
@@ -75,18 +78,33 @@ export default defineConfig({
7578
'./components/progress-bar': './app/components/progress-bar',
7679
},
7780
shared: {
78-
react: {
81+
'react-router': {
7982
singleton: true,
8083
},
81-
'react/jsx-dev-runtime': {
84+
'react-router/': {
8285
singleton: true,
8386
},
84-
'react/jsx-runtime': {
87+
'react-router-dom': {
88+
singleton: true,
89+
},
90+
react: {
91+
singleton: true,
92+
},
93+
'react/': {
8594
singleton: true,
8695
},
96+
// 'react/jsx-dev-runtime': {
97+
// singleton: true,
98+
// },
99+
// 'react/jsx-runtime': {
100+
// singleton: true,
101+
// },
87102
'react-dom': {
88103
singleton: true,
89104
},
105+
'react-dom/client': {
106+
singleton: true,
107+
},
90108
}
91109
})
92110
]
@@ -120,9 +138,18 @@ export default defineConfig({
120138

121139
},
122140
shared: {
141+
"react-router": {
142+
singleton: true
143+
},
144+
'react-router-dom': {
145+
singleton: true,
146+
},
123147
react: {
124148
singleton: true,
125149
},
150+
'react/': {
151+
singleton: true,
152+
},
126153
'react/jsx-dev-runtime': {
127154
singleton: true,
128155
},
@@ -132,6 +159,9 @@ export default defineConfig({
132159
'react-dom': {
133160
singleton: true,
134161
},
162+
'react-dom/': {
163+
singleton: true,
164+
},
135165
}
136166
})
137167
]

examples/federation/epic-stack/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import appleTouchIconAssetUrl from './assets/favicons/apple-touch-icon.png'
1515
import faviconAssetUrl from './assets/favicons/favicon.svg'
1616
import { GeneralErrorBoundary } from './components/error-boundary.tsx'
1717
import { EpicProgress } from './components/progress-bar.tsx'
18-
import { SearchBar } from './components/search-bar.tsx'
18+
import { SearchBar } from 'remote/components/search-bar'
1919
import { useToast } from './components/toaster.tsx'
2020
import { Button } from './components/ui/button.tsx'
2121
import { href as iconsHref } from './components/ui/icon.tsx'

examples/federation/epic-stack/app/routes/users+/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { data, redirect, Link } from 'react-router'
22
import { z } from 'zod'
33
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
44
import { ErrorList } from '#app/components/forms.tsx'
5-
import { SearchBar } from '#app/components/search-bar.tsx'
5+
import { SearchBar } from 'remote/components/search-bar'
66
import { prisma } from '#app/utils/db.server.ts'
77
import { cn, getUserImgSrc, useDelayedIsPending } from '#app/utils/misc.tsx'
88
import { type Route } from './+types/index.ts'

examples/federation/epic-stack/rsbuild.config.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default defineConfig({
1717
output: {
1818
externals: ['better-sqlite3', 'express', 'ws'],
1919
},
20+
resolve: {
21+
dedupe: ['react', 'react-dom'],
22+
},
2023
environments: {
2124
web: {
2225
source: {
@@ -35,18 +38,33 @@ export default defineConfig({
3538
remote: 'http://localhost:3001/static/js/remote.js',
3639
},
3740
shared: {
38-
react: {
41+
'react-router': {
3942
singleton: true,
4043
},
41-
'react/jsx-dev-runtime': {
44+
'react-router/': {
4245
singleton: true,
4346
},
44-
'react/jsx-runtime': {
47+
'react-router-dom': {
48+
singleton: true,
49+
},
50+
react: {
4551
singleton: true,
4652
},
53+
'react/': {
54+
singleton: true,
55+
},
56+
// 'react/jsx-dev-runtime': {
57+
// singleton: true,
58+
// },
59+
// 'react/jsx-runtime': {
60+
// singleton: true,
61+
// },
4762
'react-dom': {
4863
singleton: true,
4964
},
65+
'react-dom/client': {
66+
singleton: true,
67+
},
5068
},
5169
}),
5270
],
@@ -73,9 +91,18 @@ export default defineConfig({
7391
},
7492
runtimePlugins: ['@module-federation/node/runtimePlugin'],
7593
shared: {
94+
"react-router": {
95+
singleton: true,
96+
},
97+
'react-router-dom': {
98+
singleton: true,
99+
},
76100
react: {
77101
singleton: true,
78102
},
103+
'react/': {
104+
singleton: true,
105+
},
79106
'react/jsx-dev-runtime': {
80107
singleton: true,
81108
},
@@ -85,6 +112,9 @@ export default defineConfig({
85112
'react-dom': {
86113
singleton: true,
87114
},
115+
'react-dom/': {
116+
singleton: true,
117+
},
88118
},
89119
}),
90120
],

0 commit comments

Comments
 (0)