Skip to content

Commit

Permalink
chore: support resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 6, 2023
1 parent 939c81d commit 6929bca
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/vitest/src/runtime/external-executor.ts
Expand Up @@ -87,6 +87,8 @@ const SourceTextModule: typeof VMSourceTextModule = (vm as any).SourceTextModule

const _require = createRequire(import.meta.url)

const nativeResolve = import.meta.resolve

// TODO: improve Node.js strict mode support in #2854
export class ExternalModulesExecutor {
private context: vm.Context
Expand Down Expand Up @@ -247,9 +249,11 @@ export class ExternalModulesExecutor {
importModuleDynamically: this.importModuleDynamically,
initializeImportMeta: (meta, mod) => {
meta.url = mod.identifier
// TODO: improve Node.js support with #2854
// meta.resolve = (specifier: string, importer?: string) =>
// this.resolveAsync(specifier, importer ?? mod.identifier)
if (nativeResolve) {
meta.resolve = (specifier: string, importer?: string) => {
return nativeResolve(specifier, importer ?? mod.identifier)
}
}
},
},
)
Expand Down

0 comments on commit 6929bca

Please sign in to comment.