Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vitest): support older NodeJS with async import.meta.resolve #5045

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/vitest/src/runtime/external-executor.ts
Original file line number Diff line number Diff line change
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
Loading