@@ -13,7 +13,7 @@ import type {
1313  TemplateLiteral , 
1414}  from  'estree' 
1515import  {  parseExpressionAt  }  from  'acorn' 
16- import  type  {  RollupError  }  from  'rollup' 
16+ import  type  {  CustomPluginOptions ,   RollupError  }  from  'rollup' 
1717import  {  findNodeAt  }  from  'acorn-walk' 
1818import  MagicString  from  'magic-string' 
1919import  fg  from  'fast-glob' 
@@ -75,7 +75,8 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
7575        code , 
7676        id , 
7777        config . root , 
78-         ( im )  =>  this . resolve ( im ,  id ) . then ( ( i )  =>  i ?. id  ||  im ) , 
78+         ( im ,  _ ,  options )  => 
79+           this . resolve ( im ,  id ,  options ) . then ( ( i )  =>  i ?. id  ||  im ) , 
7980        config . isProduction , 
8081        config . experimental . importGlobRestoreExtension , 
8182      ) 
@@ -546,6 +547,12 @@ export async function transformGlobImport(
546547type  IdResolver  =  ( 
547548  id : string , 
548549  importer ?: string , 
550+   options ?: { 
551+     assertions ?: Record < string ,  string > 
552+     custom ?: CustomPluginOptions 
553+     isEntry ?: boolean 
554+     skipSelf ?: boolean 
555+   } , 
549556)  =>  Promise < string  |  undefined >  |  string  |  undefined 
550557
551558function  globSafePath ( path : string )  { 
@@ -594,7 +601,16 @@ export async function toAbsoluteGlob(
594601  if  ( glob . startsWith ( '../' ) )  return  pre  +  posix . join ( dir ,  glob ) 
595602  if  ( glob . startsWith ( '**' ) )  return  pre  +  glob 
596603
597-   const  resolved  =  normalizePath ( ( await  resolveId ( glob ,  importer ) )  ||  glob ) 
604+   const  isSubImportsPattern  =  glob . startsWith ( '#' )  &&  glob . includes ( '*' ) 
605+ 
606+   const  resolved  =  normalizePath ( 
607+     ( await  resolveId ( glob ,  importer ,  { 
608+       custom : {  'vite:import-glob' : {  isSubImportsPattern }  } , 
609+     } ) )  ||  glob , 
610+   ) 
611+   if  ( isSubImportsPattern )  { 
612+     return  join ( root ,  resolved ) 
613+   } 
598614  if  ( isAbsolute ( resolved ) )  { 
599615    return  pre  +  globSafeResolvedPath ( resolved ,  glob ) 
600616  } 
0 commit comments