provide a configuration similar to the configuration provided to the unResolveFactory function that you are trying to "unresolve"/"unhook" from.
provide the current plugin setup's build: esbuild.PluginBuild
parameter,
so that returned unresolver function can call build.resolve(...)
in order to acquire the natural resolved results from potentially external plugins (or the native behavior).
a path resolver function, under a specific namespace
, that can be passed to esbuild.PluginBuild.onResolve, so that the namespace can be stripped away,
and so that the path and args
can be resolved naturally by other plugins or by esbuild's file native resolver.
a path resolution factory function for esbuild.PluginBuild.onResolve, similar to onResolveFactory, but it "unhooks" any current
args.namespace
.given a certain esbuild esbuild.OnResolveArgs |
args
, and your expected resolved esbuild.OnResolveResult |result
, here is how the returned resolver function works:args.namespace
and replaces it with the backedup original one inargs.pluginData.originalNamespace
(assuming it exists, otherwise the namespace will becomeundefined
).args
is resolved using the same mechanism in the returned function of the onResolveFactory factory.build.resolve
with thenamespace
set toargs.pluginData.originalNamespace
, so that it resolves naturally, by giving other plugins the chance to intercept it (including esbuild's native file resolution and built-in "node_module" resolution).result
is then returned, thereby changing the potentialbuild.onLoad
loader function that esbuild will then call (that's becauseresult.namespace
could possibly shift to something different from the initialarg.namespace
, thereby our plugin's path-resolution and path-loading will not remain in a continuous cycle of the same namespace, since it'll give other plugins the chance to resolve and load it as well).