@oazmi/esbuild-plugin-deno - v0.4.0
    Preparing search index...

    Function resolverPlugin

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

      Parameters

      • Optionalconfig: {
            runtimePackage?: { enabled?: boolean };
            importMap?: {
                enabled?: boolean;
                globalImportMap?: { [key: string]: undefined | string };
            };
            nodeModules?: { enabled?: boolean };
            relativePath?: {
                enabled?: boolean;
                resolvePath?: (path?: string, importer?: string) => string;
                isAbsolutePath?: (segment: string) => boolean;
            };
            namespace?: string;
            log?: boolean
            | LoggerFunction;
        }
        • OptionalruntimePackage?: { enabled?: boolean }

          configuration for the runtime-package resolver in resolverPluginSetup, which operates on the CommonPluginData.runtimePackage plugin-data property.

          • Optionalenabled?: boolean

            enable or disable runtime-package (such as "deno.json") alias resolution.

            true (enabled)

        • OptionalimportMap?: { enabled?: boolean; globalImportMap?: { [key: string]: undefined | string } }

          configuration for the import-map resolver in resolverPluginSetup, which operates on the CommonPluginData.importMap plugin-data property.

          • Optionalenabled?: boolean

            enable or disable import-map resolution.

            true (enabled)

          • OptionalglobalImportMap?: { [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).

            {} (empty object/dictionary)

        • OptionalnodeModules?: { enabled?: boolean }

          configuration for esbuild's native node_modules resolver in resolverPluginSetup.

          • Optionalenabled?: boolean

            enable or disable node_modules resolution.

            true (enabled). however, the default pluginData.resolverConfig.useNodeModules option is set to false, meaning that it will only work when the user explicitly sets their pluginData.resolverConfig.useNodeModules to true.

        • OptionalrelativePath?: {
              enabled?: boolean;
              resolvePath?: (path?: string, importer?: string) => string;
              isAbsolutePath?: (segment: string) => boolean;
          }

          configuration for the relative-path resolver in resolverPluginSetup.

          • Optionalenabled?: boolean

            enable or disable relative path resolution.

            true (enabled)

          • OptionalresolvePath?: (path?: string, importer?: string) => string

            a 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:

            1. if path is undefined or an empty string, then the current working directory should be returned.
            2. if the path begins with a leading slash ("/"), you should treat it as a root-path and join it with the 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).
            3. if the path is an absolute path of some kind, you should simply return it as is, after ensuring posix separators ("/") are being used.
            4. finally, for all remaining cases (i.e. relative paths, which begin with either "./", "../", or a bare file subpath), you should join them with their importer if it is present, otherwise join them with your current working directory (or absWorkingDir).
          • OptionalisAbsolutePath?: (segment: string) => boolean

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

        • Optionalnamespace?: string

          specify the input-namespace on which the resolver-pipeline will operate on.

          Caution

          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.

        • Optionallog?: boolean | LoggerFunction

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

          false

      Returns Plugin