@@ -218,6 +218,7 @@ const devHtmlHook: IndexHtmlTransformHook = async (
218218 )
219219 const styleUrl : AssetNode [ ] = [ ]
220220 const inlineStyles : InlineStyleAttribute [ ] = [ ]
221+ const inlineModulePaths : string [ ] = [ ]
221222
222223 const addInlineModule = (
223224 node : DefaultTreeAdapterMap [ 'element' ] ,
@@ -246,13 +247,8 @@ const devHtmlHook: IndexHtmlTransformHook = async (
246247
247248 // inline js module. convert to src="proxy" (dev only, base is never relative)
248249 const modulePath = `${ proxyModuleUrl } ?html-proxy&index=${ inlineModuleIndex } .${ ext } `
250+ inlineModulePaths . push ( modulePath )
249251
250- // invalidate the module so the newly cached contents will be served
251- const clientModuleGraph = server ?. environments . client . moduleGraph
252- const module = clientModuleGraph ?. getModuleById ( modulePath )
253- if ( module ) {
254- clientModuleGraph ! . invalidateModule ( module )
255- }
256252 s . update (
257253 node . sourceCodeLocation ! . startOffset ,
258254 node . sourceCodeLocation ! . endOffset ,
@@ -350,6 +346,19 @@ const devHtmlHook: IndexHtmlTransformHook = async (
350346 }
351347 } )
352348
349+ // invalidate the module so the newly cached contents will be served
350+ const clientModuelGraph = server ?. environments . client . moduleGraph
351+ if ( clientModuelGraph ) {
352+ await Promise . all (
353+ inlineModulePaths . map ( async ( url ) => {
354+ const module = await clientModuelGraph . getModuleByUrl ( url )
355+ if ( module ) {
356+ clientModuelGraph . invalidateModule ( module )
357+ }
358+ } ) ,
359+ )
360+ }
361+
353362 await Promise . all ( [
354363 ...styleUrl . map ( async ( { start, end, code } , index ) => {
355364 const url = `${ proxyModulePath } ?html-proxy&direct&index=${ index } .css`
0 commit comments