File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change 11import  type  {  DevEnvironment  }  from  'vite' 
22import  type  {  ResolvedConfig  }  from  '../types/config' 
33import  type  {  VitestFetchFunction  }  from  './fetchModule' 
4- import  {  builtinModules  }  from  'node:module' 
54import  {  VitestModuleEvaluator  }  from  '#module-evaluator' 
65import  {  ModuleRunner  }  from  'vite/module-runner' 
76import  {  normalizeResolvedIdToUrl  }  from  './normalizeUrl' 
87
9- const  nodeBuiltins  =  builtinModules . filter ( id  =>  ! id . includes ( ':' ) ) 
10- 
118export  class  ServerModuleRunner  extends  ModuleRunner  { 
129  constructor ( 
1310    private  environment : DevEnvironment , 
@@ -24,7 +21,7 @@ export class ServerModuleRunner extends ModuleRunner {
2421            } 
2522            const  {  name,  data }  =  event . data 
2623            if  ( name  ===  'getBuiltins' )  { 
27-               return  {   result :  [ ... nodeBuiltins ,   / ^ n o d e : / ]   } 
24+               return  await   environment . hot . handleInvoke ( event ) 
2825            } 
2926            if  ( name  !==  'fetchModule' )  { 
3027              return  {  error : new  Error ( `Unknown method: ${ name }  . Expected "fetchModule".` )  } 
Original file line number Diff line number Diff line change 11import  type  {  FetchFunction ,  ModuleRunnerTransport  }  from  'vite/module-runner' 
22import  type  {  ResolveFunctionResult  }  from  '../../types/general' 
3- import  {  builtinModules  }  from  'node:module' 
43
54export  interface  VitestTransportOptions  { 
65  fetchModule : FetchFunction 
76  resolveId : ( id : string ,  importer ?: string )  =>  Promise < ResolveFunctionResult  |  null > 
87} 
98
10- const  nodeBuiltins  =  builtinModules . filter ( id  =>  ! id . includes ( ':' ) ) 
11- 
129export  class  VitestTransport  implements  ModuleRunnerTransport  { 
1310  constructor ( private  options : VitestTransportOptions )  { } 
1411
@@ -21,7 +18,9 @@ export class VitestTransport implements ModuleRunnerTransport {
2118    } 
2219    const  {  name,  data }  =  event . data 
2320    if  ( name  ===  'getBuiltins' )  { 
24-       return  {  result : [ ...nodeBuiltins ,  / ^ n o d e : / ]  } 
21+       // we return an empty array here to avoid client-side builtin check, 
22+       // as we need builtins to go through `fetchModule` 
23+       return  {  result : [ ]  } 
2524    } 
2625    if  ( name  !==  'fetchModule' )  { 
2726      return  {  error : new  Error ( `Unknown method: ${ name }  . Expected "fetchModule".` )  } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments