The resolve
hook chain is responsible for telling Node.js where to find and how to cache a given import
statement or expression, or require
call. It can optionally return a format (such as 'module'
) as a hint to the load
hook. If a format is specified, the load
hook is ultimately responsible for providing the final format
value (and it is free to ignore the hint provided by resolve
); if resolve
provides a format
, a custom load
hook is required even if only to pass the value to the Node.js default load
hook.
type
module.default.ResolveHook
type ResolveHook = (specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context?: Partial<ResolveHookContext>) => ResolveFnOutput | Promise<ResolveFnOutput>) => ResolveFnOutput | Promise<ResolveFnOutput>