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:

  1. strips out the current args.namespace and replaces it with the backedup original one in args.pluginData.originalNamespace (assuming it exists, otherwise the namespace will become undefined).
  2. the absolute path of the input args is resolved using the same mechanism in the returned function of the onResolveFactory factory.
  3. we call ["resolve"] | build.resolve with the namespace set to args.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).
  4. the naturally resolved result is then returned, thereby changing the potential build.onLoad loader function that esbuild will then call (that's because result.namespace could possibly shift to something different from the initial arg.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).
  • Parameters

    • config: CommonPluginResolverConfig

      provide a configuration similar to the configuration provided to the unResolveFactory function that you are trying to "unresolve"/"unhook" from.

    • build: PluginBuild

      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).

    Returns (args: OnResolveArgs) => Promise<OnResolveResult>

    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.