Optional
config: {Optional
runtimePackage?: { enabled?: boolean }configuration for the runtime-package resolver in resolverPluginSetup, which operates on the CommonPluginData.runtimePackage plugin-data property.
Optional
enabled?: booleanenable or disable runtime-package (such as "deno.json") alias resolution.
Optional
importMap?: { enabled?: boolean; globalImportMap?: { [key: string]: undefined | string } }configuration for the import-map resolver in resolverPluginSetup, which operates on the CommonPluginData.importMap plugin-data property.
Optional
enabled?: booleanenable or disable import-map resolution.
Optional
globalImportMap?: { [key: string]: undefined | string }specify a global import-map for aliases to resources.
the full import-map within the body of the resolver function will be a merger between this global import-map, and the import-map acquired from the plugin data (i.e. CommonPluginData.importMap). the plugin data's import-map will take a higher priority in case of conflicting key (i.e. same alias key but different absolute path values).
the resolve function will always look for a match for args.path
inside of the import-map,
before resolving it with respect to the current importer or resolve-directory (i.e. args.importer
or args.resolveDir
).
Optional
nodeModules?: { enabled?: boolean }configuration for esbuild's native node_modules
resolver in resolverPluginSetup.
Optional
enabled?: booleanenable or disable node_modules
resolution.
Optional
relativePath?: {configuration for the relative-path resolver in resolverPluginSetup.
Optional
enabled?: booleanenable or disable relative path resolution.
Optional
resolvePath?: (path?: string, importer?: string) => stringa function that resolves a path segment to an absolute path (i.e. a path that the plugin itself can recognize as an absolute path).
this function is utilized by the relativePathResolver
function inside the plugin's body,
and it will operate independent of what your isAbsolutePath function is.
this means that you will have to check for absolute paths yourself,
because every resource that will make its way to the relativePathResolver
will be processed by this resolvePath
function.
in general, there are four checks that your path resolver function should perform in the provided order:
path
is undefined
or an empty string, then the current working directory should be returned.importer
's domain
(for instance, the domain of https://esm.sh/hello/world
would be https://esm.sh/
).
but if no importer
argument is present, then go to the next case (where you'll effectively resolve it as an absolute local unix file path).path
is an absolute path of some kind, you should simply return it as is, after ensuring posix separators ("/"
) are being used.importer
if it is present, otherwise join them with your current working directory (or absWorkingDir
).Optional
isAbsolutePath?: (segment: string) => booleana function that declares whether or not a given path segment is an absolute path (i.e. the plugin itself recognizes it as an absolute path).
Optional
namespace?: stringspecify the input-namespace on which the resolver-pipeline will operate on.
it is best if you don't modify it to something besides the default value PLUGIN_NAMESPACE.RESOLVER_PIPELINE, as the filter-category plugins rely on that specific namespace to have their intercepted entities resolved as absolute-paths.
Optional
log?: boolean | LoggerFunctionenable logging of the input arguments and resolved paths, when DEBUG.LOG is ennabled.
when set to true
, the logs will show up in your console via console.log()
.
you may also provide your own custom logger function if you wish.
this is a 4-in-1 namespaced-plugin that assists in resolving esbuild paths, based on
pluginData
, esbuild's native-resolver, and relative path resolver.for details on what gets resolved an how, refer to the documentation comments of this submodule ("plugins/resolvers").
the way it is intended to be used is by being called indirectly via
build.resolve
, after specifying the correct namespace of this plugin.