@@ -40,7 +40,6 @@ import {
4040import  {  cjsModuleRunnerPlugin  }  from  './plugins/cjs' 
4141import  {  evalValue ,  parseIdQuery  }  from  './plugins/utils' 
4242import  {  createDebug  }  from  '@hiogawa/utils' 
43- import  {  scanBuildStrip  }  from  './plugins/scan' 
4443
4544// state for build orchestration 
4645let  serverReferences : Record < string ,  string >  =  { } 
@@ -902,14 +901,28 @@ globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;
902901  ] 
903902} 
904903
904+ // https://github.com/vitejs/vite/blob/86d2e8be50be535494734f9f5f5236c61626b308/packages/vite/src/node/plugins/importMetaGlob.ts#L113 
905+ const  importGlobRE  =  / \b i m p o r t \. m e t a \. g l o b (?: < \w + > ) ? \s * \( / g
906+ 
907+ // During scan build, we strip all code but imports to 
908+ // traverse module graph faster and just discover client/server references. 
905909function  scanBuildStripPlugin ( ) : Plugin  { 
906910  return  { 
907911    name : 'rsc:scan-strip' , 
908912    apply : 'build' , 
909913    enforce : 'post' , 
910914    transform ( code ,  _id ,  _options )  { 
911915      if  ( ! isScanBuild )  return 
912-       const  output  =  scanBuildStrip ( code ) 
916+ 
917+       // bail out if import.meta.glob 
918+       // https://github.com/vitejs/rolldown-vite/issues/373 
919+       if  ( importGlobRE . test ( code ) )  return  code 
920+ 
921+       const  [ imports ]  =  esModuleLexer . parse ( code ) 
922+       const  output  =  imports 
923+         . map ( ( e )  =>  e . n  &&  `import ${ JSON . stringify ( e . n ) }  ;\n` ) 
924+         . filter ( Boolean ) 
925+         . join ( '' ) 
913926      return  {  code : output ,  map : {  mappings : ''  }  } 
914927    } , 
915928  } 
0 commit comments