a factory function that returns a general purpose path resolver function for your esbuild plugin, tuned to your specific config.
config
given a certain esbuild esbuild.OnResolveArgs | args, and your expected resolved esbuild.OnResolveResult | result here is what the returned resolver function takes care of:
args
result
result.path
args.parse
config.isAbsolutePath(args.parse) === true
config.isAbsolutePath(args.parse) === false
dir
args.importer
args.resolveDir
config.resolvePath
result.namespace
config.namespace
args.namespace
config.pluginData.originalNamespace
result.pluginData.importMap
args.pluginData.importMap
provide a configuration for this factory function.
a path resolver function that can be passed to esbuild.PluginBuild.onResolve. the resolver function will resolve any relative paths to absolute ones, and set the namespace to config.namespace.
a factory function that returns a general purpose path resolver function for your esbuild plugin, tuned to your specific
config
.given a certain esbuild esbuild.OnResolveArgs |
args
, and your expected resolved esbuild.OnResolveResult |result
here is what the returned resolver function takes care of:result.path
:args.parse
is an absolute path (i.e. whenconfig.isAbsolutePath(args.parse) === true
), then it will be returned as is.args.parse
is a relative path (i.e. whenconfig.isAbsolutePath(args.parse) === false
), then:dir
, by:args.importer
withargs.resolveDir
(viaconfig.resolvePath
) ifargs.importer
is not absolute.dir
toargs.importer
if it is absolute.dir
withargs.parse
usingconfig.resolvePath
and return it asresult.path
.result.namespace
toconfig.namespace
args.namespace
toconfig.pluginData.originalNamespace
result.pluginData.importMap
toargs.pluginData.importMap
(which is originally set by the loaders of our typical plugin)