@@ -85,6 +85,7 @@ type Options = {
8585
8686const react = ( _options ?: Options ) : PluginOption [ ] => {
8787 let hmrDisabled = false
88+ let base : string
8889 const options = {
8990 jsxImportSource : _options ?. jsxImportSource ?? 'react' ,
9091 tsDecorators : _options ?. tsDecorators ,
@@ -99,7 +100,6 @@ const react = (_options?: Options): PluginOption[] => {
99100 disableOxcRecommendation : _options ?. disableOxcRecommendation ,
100101 }
101102
102- let base : string | undefined
103103 return [
104104 {
105105 name : 'vite:react-swc:resolve-runtime' ,
@@ -140,6 +140,8 @@ const react = (_options?: Options): PluginOption[] => {
140140 configResolved ( config ) {
141141 base = config . base
142142 if ( config . server . hmr === false ) hmrDisabled = true
143+ base = config . base
144+
143145 const mdxIndex = config . plugins . findIndex (
144146 ( p ) => p . name === '@mdx-js/rollup' ,
145147 )
@@ -165,21 +167,19 @@ const react = (_options?: Options): PluginOption[] => {
165167 }
166168 } ,
167169 transformIndexHtml : {
170+ // TODO: maybe we can inject this to entrypoints instead of index.html?
168171 handler ( ) {
169- if ( ! hmrDisabled ) {
172+ if ( ! hmrDisabled )
170173 return [
171174 {
172175 tag : 'script' ,
173176 attrs : { type : 'module' } ,
174- // !!! Rolldown vite full bunlde module break changes, config.server is invalid
175- // children: getPreambleCode(config.server!.config.base),
176- children : getPreambleCode ( base ! ) ,
177+ children : getPreambleCode ( base ) ,
177178 } ,
178179 ]
179- }
180180 } ,
181- // Rolldown vite full bunlde module break changes .
182- // Changed it to make sure the inject module could be bundled
181+ // In unbundled mode, Vite transforms any requests .
182+ // But in full bundled mode, Vite only transforms / bundles the scripts injected in `order: 'pre'`.
183183 order : 'pre' ,
184184 } ,
185185 async transform ( code , _id , transformOptions ) {
0 commit comments