File tree 3 files changed +23
-15
lines changed
3 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,23 @@ export let rescriptRelayVitePlugin = ({
85
85
86
86
return {
87
87
name : "rescript-relay" ,
88
+ /**
89
+ * Workaround until we can upgrade to Vite 3.
90
+ *
91
+ * Remove manualChunks if this is SSR, since it doesn't work in SSR mode.
92
+ * See https://github.com/vitejs/vite/issues/8836
93
+ */
94
+ config ( userConfig ) {
95
+ //
96
+ if (
97
+ Boolean ( userConfig . build . ssr ) &&
98
+ userConfig . build ?. rollupOptions ?. output ?. manualChunks != null
99
+ ) {
100
+ delete userConfig . build . rollupOptions . output . manualChunks ;
101
+ }
102
+
103
+ return userConfig ;
104
+ } ,
88
105
/**
89
106
* @param {ResolvedConfig } resolvedConfig
90
107
*/
Original file line number Diff line number Diff line change 11
11
"build:rescript" : " rescript build -with-deps" ,
12
12
"build:vite" : " run-s build:vite:*" ,
13
13
"build:vite:client" : " vite build --outDir dist/client --ssrManifest --manifest" ,
14
- "build:vite:server" : " cross-env IS_VITE_SSR=1 vite build --outDir dist/server --ssr src/EntryServer.mjs" ,
14
+ "build:vite:server" : " vite build --outDir dist/server --ssr src/EntryServer.mjs" ,
15
15
"build:vite:server-fix" : " perl -i -pe 's/import \\ * as ReactRelay/import ReactRelay/' dist/server/EntryServer.js" ,
16
16
"preview" : " cross-env ENABLE_FILESERVER=true yarn start" ,
17
17
"start" : " cross-env NODE_ENV=production node Server.mjs" ,
Original file line number Diff line number Diff line change @@ -24,20 +24,11 @@ export default defineConfig({
24
24
plugins : [ visualizer ( ) ] ,
25
25
output : {
26
26
format : "esm" ,
27
- // Only enable output chunking for our client bundle.
28
- // At the time of writing Vite does not allow us to know when --ssr
29
- // is passed so we use a custom env variable.
30
- ...(
31
- process . env . IS_VITE_SSR === "1"
32
- ? { }
33
- : {
34
- manualChunks : {
35
- react : [ "react" , "react-dom" ] ,
36
- relay : [ "react-relay" , "relay-runtime" ] ,
37
- vendor : [ "react-helmet" ] ,
38
- }
39
- }
40
- ) ,
27
+ manualChunks : {
28
+ react : [ "react" , "react-dom" ] ,
29
+ relay : [ "react-relay" , "relay-runtime" ] ,
30
+ vendor : [ "react-helmet" ] ,
31
+ } ,
41
32
} ,
42
33
} ,
43
34
} ,
You can’t perform that action at this time.
0 commit comments