File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
packages/vitest/src/runtime/moduleRunner Expand file tree Collapse file tree 1 file changed +6
-0
lines changed 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'
34
45export interface VitestTransportOptions {
56 fetchModule : FetchFunction
67 resolveId : ( id : string , importer ?: string ) => Promise < ResolveFunctionResult | null >
78}
89
10+ const nodeBuiltins = builtinModules . filter ( id => ! id . includes ( ':' ) )
11+
912export class VitestTransport implements ModuleRunnerTransport {
1013 constructor ( private options : VitestTransportOptions ) { }
1114
@@ -20,6 +23,9 @@ export class VitestTransport implements ModuleRunnerTransport {
2023 if ( name !== 'fetchModule' ) {
2124 return { error : new Error ( `Unknown method: ${ name } . Expected "fetchModule".` ) }
2225 }
26+ if ( name === 'getBuiltins' ) {
27+ return { result : [ ...nodeBuiltins , / ^ n o d e : / ] }
28+ }
2329 try {
2430 const result = await this . options . fetchModule ( ...data as Parameters < FetchFunction > )
2531 return { result }
You can’t perform that action at this time.
0 commit comments