@@ -91,6 +91,7 @@ const react = (_options?: Options): PluginOption[] => {
91
91
_options ?. useAtYourOwnRisk_mutateSwcOptions ,
92
92
}
93
93
94
+ let base : string | undefined
94
95
return [
95
96
{
96
97
name : 'vite:react-swc:resolve-runtime' ,
@@ -118,6 +119,7 @@ const react = (_options?: Options): PluginOption[] => {
118
119
} ,
119
120
} ) ,
120
121
configResolved ( config ) {
122
+ base = config . base
121
123
if ( config . server . hmr === false ) hmrDisabled = true
122
124
const mdxIndex = config . plugins . findIndex (
123
125
( p ) => p . name === '@mdx-js/rollup' ,
@@ -132,13 +134,22 @@ const react = (_options?: Options): PluginOption[] => {
132
134
)
133
135
}
134
136
} ,
135
- transformIndexHtml : ( _ , config ) => [
136
- {
137
- tag : 'script' ,
138
- attrs : { type : 'module' } ,
139
- children : getPreambleCode ( config . server ! . config . base ) ,
137
+ transformIndexHtml : {
138
+ handler ( ) {
139
+ return [
140
+ {
141
+ tag : 'script' ,
142
+ attrs : { type : 'module' } ,
143
+ // !!! Rolldown vite full bunlde module break changes, config.server is invalid
144
+ // children: getPreambleCode(config.server!.config.base),
145
+ children : getPreambleCode ( base ! ) ,
146
+ } ,
147
+ ]
140
148
} ,
141
- ] ,
149
+ // Rolldown vite full bunlde module break changes.
150
+ // Changed it to make sure the inject module could be bundled
151
+ order : 'pre' ,
152
+ } ,
142
153
async transform ( code , _id , transformOptions ) {
143
154
const id = _id . split ( '?' ) [ 0 ]
144
155
const refresh = ! transformOptions ?. ssr && ! hmrDisabled
0 commit comments