Skip to content

Commit

Permalink
fix(vitest): support older NodeJS with async import.meta.resolve (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Jan 26, 2024
1 parent 915d6c4 commit cf5641a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vitest/src/runtime/external-executor.ts
Expand Up @@ -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<string>

if (identifier instanceof Promise)
identifier = await identifier

return await this.createModule(identifier)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit cf5641a

Please sign in to comment.