global import-maps will intercept all onResolve calls made by esbuild once,
before handing the entity in question to some other plugin to resolve (or letting esbuild do its native resolution).
if the entity's path (args.path) is a part of the import-map in the config (ImportMapPluginSetupConfig.importMap),
then this plugin will transform its path before handing it over to some other plugin to resolve.
you may wonder, how does this plugin not end up in a recursive infinite loop of onResolve calls, when it captures everything?
the way it works is that the first time an entity is encountered, we insert a unique symbol (CAPTURED_ALREADY) inside args.pluginData.
and upon the discovery of the same symbol in a recursive/subsequent call, we terminate the path-resolution (by returning undefined),
so that esbuild uses the next available path-resolver for this entity.
setup function for a global import-map plugin.
global import-maps will intercept all
onResolve
calls made by esbuild once, before handing the entity in question to some other plugin to resolve (or letting esbuild do its native resolution). if the entity's path (args.path
) is a part of the import-map in the config (ImportMapPluginSetupConfig.importMap), then this plugin will transform its path before handing it over to some other plugin to resolve.for details on how to configure, see ImportMapPluginSetupConfig.
you may wonder, how does this plugin not end up in a recursive infinite loop of
onResolve
calls, when it captures everything?the way it works is that the first time an entity is encountered, we insert a unique symbol (CAPTURED_ALREADY) inside
args.pluginData
. and upon the discovery of the same symbol in a recursive/subsequent call, we terminate the path-resolution (by returningundefined
), so that esbuild uses the next available path-resolver for this entity.