@@ -91,6 +91,7 @@ const react = (_options?: Options): PluginOption[] => {
9191 _options ?. useAtYourOwnRisk_mutateSwcOptions ,
9292 }
9393
94+ let base : string | undefined
9495 return [
9596 {
9697 name : 'vite:react-swc:resolve-runtime' ,
@@ -118,6 +119,7 @@ const react = (_options?: Options): PluginOption[] => {
118119 } ,
119120 } ) ,
120121 configResolved ( config ) {
122+ base = config . base
121123 if ( config . server . hmr === false ) hmrDisabled = true
122124 const mdxIndex = config . plugins . findIndex (
123125 ( p ) => p . name === '@mdx-js/rollup' ,
@@ -132,13 +134,22 @@ const react = (_options?: Options): PluginOption[] => {
132134 )
133135 }
134136 } ,
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+ ]
140148 } ,
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+ } ,
142153 async transform ( code , _id , transformOptions ) {
143154 const id = _id . split ( '?' ) [ 0 ]
144155 const refresh = ! transformOptions ?. ssr && ! hmrDisabled
0 commit comments