diff --git a/packages/vitest/src/runtime/external-executor.ts b/packages/vitest/src/runtime/external-executor.ts index 7bb526005ae2..5093ab6c8a1f 100644 --- a/packages/vitest/src/runtime/external-executor.ts +++ b/packages/vitest/src/runtime/external-executor.ts @@ -71,7 +71,11 @@ export class ExternalModulesExecutor { } public resolveModule = async (specifier: string, referencer: string) => { - const identifier = this.resolve(specifier, referencer) + let identifier = this.resolve(specifier, referencer) as string | Promise + + if (identifier instanceof Promise) + identifier = await identifier + return await this.createModule(identifier) } @@ -81,6 +85,8 @@ export class ExternalModulesExecutor { if (id) return id } + + // import.meta.resolve can be asynchronous in older +18 Node versions return nativeResolve(specifier, parent) }