@@ -92,6 +92,7 @@ const react = (_options?: Options): PluginOption[] => {
92
92
_options ?. useAtYourOwnRisk_mutateSwcOptions ,
93
93
}
94
94
95
+ let base : string | undefined
95
96
return [
96
97
{
97
98
name : 'vite:react-swc:resolve-runtime' ,
@@ -128,6 +129,7 @@ const react = (_options?: Options): PluginOption[] => {
128
129
} ,
129
130
} ) ,
130
131
configResolved ( config ) {
132
+ base = config . base
131
133
if ( config . server . hmr === false ) hmrDisabled = true
132
134
const mdxIndex = config . plugins . findIndex (
133
135
( p ) => p . name === '@mdx-js/rollup' ,
@@ -142,16 +144,23 @@ const react = (_options?: Options): PluginOption[] => {
142
144
)
143
145
}
144
146
} ,
145
- transformIndexHtml : ( _ , config ) => {
146
- if ( ! hmrDisabled ) {
147
- return [
148
- {
149
- tag : 'script' ,
150
- attrs : { type : 'module' } ,
151
- children : getPreambleCode ( config . server ! . config . base ) ,
152
- } ,
153
- ]
154
- }
147
+ transformIndexHtml : {
148
+ handler ( ) {
149
+ if ( ! hmrDisabled ) {
150
+ return [
151
+ {
152
+ tag : 'script' ,
153
+ attrs : { type : 'module' } ,
154
+ // !!! Rolldown vite full bunlde module break changes, config.server is invalid
155
+ // children: getPreambleCode(config.server!.config.base),
156
+ children : getPreambleCode ( base ! ) ,
157
+ } ,
158
+ ]
159
+ }
160
+ } ,
161
+ // Rolldown vite full bunlde module break changes.
162
+ // Changed it to make sure the inject module could be bundled
163
+ order : 'pre' ,
155
164
} ,
156
165
async transform ( code , _id , transformOptions ) {
157
166
const id = _id . split ( '?' ) [ 0 ]
0 commit comments