enhanced-resolve

  • Version 5.19.0
  • Published
  • 248 kB
  • 2 dependencies
  • MIT license

Install

npm i enhanced-resolve
yarn add enhanced-resolve
pnpm add enhanced-resolve

Overview

Offers a async require.resolve function. It's highly configurable.

Index

Variables

variable sync

const sync: ResolveFunction;

    Functions

    function create

    create: typeof create;

      function exports

      exports: typeof exports;

        function forEachBail

        forEachBail: <T, Z>(
        array: T[],
        iterator: Iterator<T, Z>,
        callback: (err?: null | Error, result?: Z, i?: number) => void
        ) => void;

          Classes

          class CachedInputFileSystem

          class CachedInputFileSystem {}

            constructor

            constructor(fileSystem: BaseFileSystem, duration: number);

              property fileSystem

              fileSystem: BaseFileSystem;

                property lstat

                lstat?: LStat;

                  property lstatSync

                  lstatSync?: LStatSync;

                    property readdir

                    readdir: Readdir;

                      property readdirSync

                      readdirSync: ReaddirSync;

                        property readFile

                        readFile: ReadFile;

                          property readFileSync

                          readFileSync: ReadFileSync;

                            property readJson

                            readJson?: (
                            pathOrFileDescription: PathOrFileDescriptor,
                            callback: (
                            err: null | Error | NodeJS.ErrnoException,
                            result?: JsonObject
                            ) => void
                            ) => void;

                              property readJsonSync

                              readJsonSync?: (pathOrFileDescription: PathOrFileDescriptor) => JsonObject;
                                readlink: Readlink;

                                  property readlinkSync

                                  readlinkSync: ReadlinkSync;

                                    property realpath

                                    realpath?: RealPath;

                                      property realpathSync

                                      realpathSync?: RealPathSync;

                                        property stat

                                        stat: Stat;

                                          property statSync

                                          statSync: StatSync;

                                            method purge

                                            purge: (
                                            what?:
                                            | string
                                            | number
                                            | Buffer
                                            | URL_url
                                            | (string | number | Buffer | URL_url)[]
                                            | Set<string | number | Buffer | URL_url>
                                            ) => void;

                                              class CloneBasenamePlugin

                                              class CloneBasenamePlugin {}

                                                constructor

                                                constructor(source: any, target: any);

                                                  property source

                                                  source: any;

                                                    property target

                                                    target: any;

                                                      method apply

                                                      apply: (resolver: Resolver) => void;

                                                        class LogInfoPlugin

                                                        class LogInfoPlugin {}

                                                          constructor

                                                          constructor(source: any);

                                                            property source

                                                            source: any;

                                                              method apply

                                                              apply: (resolver: Resolver) => void;

                                                                class Resolver

                                                                abstract class Resolver {}

                                                                  property fileSystem

                                                                  fileSystem: FileSystem;

                                                                    property hooks

                                                                    hooks: KnownHooks;

                                                                      property options

                                                                      options: ResolveOptionsResolverFactoryObject_1;

                                                                        method doResolve

                                                                        doResolve: (
                                                                        hook: AsyncSeriesBailHook<[ResolveRequest, ResolveContext], ResolveRequest>,
                                                                        request: ResolveRequest,
                                                                        message: null | string,
                                                                        resolveContext: ResolveContext,
                                                                        callback: (err?: null | Error, result?: ResolveRequest) => void
                                                                        ) => void;

                                                                          method ensureHook

                                                                          ensureHook: (
                                                                          name:
                                                                          | string
                                                                          | AsyncSeriesBailHook<
                                                                          [ResolveRequest, ResolveContext],
                                                                          null | ResolveRequest
                                                                          >
                                                                          ) => AsyncSeriesBailHook<[ResolveRequest, ResolveContext], ResolveRequest>;

                                                                            method getHook

                                                                            getHook: (
                                                                            name:
                                                                            | string
                                                                            | AsyncSeriesBailHook<
                                                                            [ResolveRequest, ResolveContext],
                                                                            null | ResolveRequest
                                                                            >
                                                                            ) => AsyncSeriesBailHook<[ResolveRequest, ResolveContext], ResolveRequest>;

                                                                              method isDirectory

                                                                              isDirectory: (path: string) => boolean;

                                                                                method isModule

                                                                                isModule: (path: string) => boolean;

                                                                                  method isPrivate

                                                                                  isPrivate: (path: string) => boolean;

                                                                                    method join

                                                                                    join: (path: string, request: string) => string;

                                                                                      method normalize

                                                                                      normalize: (path: string) => string;

                                                                                        method parse

                                                                                        parse: (identifier: string) => ParsedIdentifier;

                                                                                          method resolve

                                                                                          resolve: (
                                                                                          context: Context,
                                                                                          path: string,
                                                                                          request: string,
                                                                                          resolveContext: ResolveContext,
                                                                                          callback: (
                                                                                          err: null | ErrorWithDetail,
                                                                                          res?: string | false,
                                                                                          req?: ResolveRequest
                                                                                          ) => void
                                                                                          ) => void;

                                                                                            method resolveSync

                                                                                            resolveSync: (context: Context, path: string, request: string) => string | false;

                                                                                              class TsconfigPathsPlugin

                                                                                              class TsconfigPathsPlugin {}

                                                                                                constructor

                                                                                                constructor(configFileOrOptions: string | true | TsconfigOptions);

                                                                                                  property configFile

                                                                                                  configFile: string;

                                                                                                    property references

                                                                                                    references: 'auto' | TsconfigReference[];

                                                                                                      method apply

                                                                                                      apply: (resolver: Resolver) => void;

                                                                                                        Interfaces

                                                                                                        interface FileSystem

                                                                                                        interface FileSystem {}

                                                                                                          property lstat

                                                                                                          lstat?: LStat;
                                                                                                          • lstat method

                                                                                                          property readdir

                                                                                                          readdir: Readdir;
                                                                                                          • readdir method

                                                                                                          property readFile

                                                                                                          readFile: ReadFile;
                                                                                                          • read file method

                                                                                                          property readJson

                                                                                                          readJson?: (
                                                                                                          pathOrFileDescription: PathOrFileDescriptor,
                                                                                                          callback: (
                                                                                                          err: null | Error | NodeJS.ErrnoException,
                                                                                                          result?: JsonObject
                                                                                                          ) => void
                                                                                                          ) => void;
                                                                                                          • read json method

                                                                                                          readlink: Readlink;
                                                                                                          • read link method

                                                                                                          property realpath

                                                                                                          realpath?: RealPath;
                                                                                                          • realpath method

                                                                                                          property stat

                                                                                                          stat: Stat;
                                                                                                          • stat method

                                                                                                          interface PnpApi

                                                                                                          interface PnpApi {}

                                                                                                            property resolveToUnqualified

                                                                                                            resolveToUnqualified: (
                                                                                                            packageName: string,
                                                                                                            issuer: string,
                                                                                                            options: { considerBuiltins: boolean }
                                                                                                            ) => null | string;
                                                                                                            • resolve to unqualified

                                                                                                            interface ResolveContext

                                                                                                            interface ResolveContext {}

                                                                                                              property contextDependencies

                                                                                                              contextDependencies?: WriteOnlySet<string>;
                                                                                                              • directories that was found on file system

                                                                                                              property fileDependencies

                                                                                                              fileDependencies?: WriteOnlySet<string>;
                                                                                                              • files that was found on file system

                                                                                                              property log

                                                                                                              log?: (str: string) => void;
                                                                                                              • log function

                                                                                                              property missingDependencies

                                                                                                              missingDependencies?: WriteOnlySet<string>;
                                                                                                              • dependencies that was not found on file system

                                                                                                              property stack

                                                                                                              stack?: Set<string>;
                                                                                                              • set of hooks' calls. For instance, resolve → parsedResolve → describedResolve,

                                                                                                              property yield

                                                                                                              yield?: (request: ResolveRequest) => void;
                                                                                                              • yield result, if provided plugins can return several results

                                                                                                              interface ResolveFunction

                                                                                                              interface ResolveFunction {}

                                                                                                                call signature

                                                                                                                (context: Context, path: string, request: string): string | false;

                                                                                                                  call signature

                                                                                                                  (path: string, request: string): string | false;

                                                                                                                    interface ResolveFunctionAsync

                                                                                                                    interface ResolveFunctionAsync {}

                                                                                                                      call signature

                                                                                                                      (
                                                                                                                      context: Context,
                                                                                                                      path: string,
                                                                                                                      request: string,
                                                                                                                      resolveContext: ResolveContext,
                                                                                                                      callback: (
                                                                                                                      err: null | ErrorWithDetail,
                                                                                                                      res?: string | false,
                                                                                                                      req?: ResolveRequest
                                                                                                                      ) => void
                                                                                                                      ): void;

                                                                                                                        call signature

                                                                                                                        (
                                                                                                                        context: Context,
                                                                                                                        path: string,
                                                                                                                        request: string,
                                                                                                                        callback: (
                                                                                                                        err: null | ErrorWithDetail,
                                                                                                                        res?: string | false,
                                                                                                                        req?: ResolveRequest
                                                                                                                        ) => void
                                                                                                                        ): void;

                                                                                                                          call signature

                                                                                                                          (
                                                                                                                          path: string,
                                                                                                                          request: string,
                                                                                                                          resolveContext: ResolveContext,
                                                                                                                          callback: (
                                                                                                                          err: null | ErrorWithDetail,
                                                                                                                          res?: string | false,
                                                                                                                          req?: ResolveRequest
                                                                                                                          ) => void
                                                                                                                          ): void;

                                                                                                                            call signature

                                                                                                                            (
                                                                                                                            path: string,
                                                                                                                            request: string,
                                                                                                                            callback: (
                                                                                                                            err: null | ErrorWithDetail,
                                                                                                                            res?: string | false,
                                                                                                                            req?: ResolveRequest
                                                                                                                            ) => void
                                                                                                                            ): void;

                                                                                                                              interface ResolveOptions

                                                                                                                              interface ResolveOptionsResolverFactoryObject_2 {}

                                                                                                                                property alias

                                                                                                                                alias?: AliasOptions | AliasOption[];
                                                                                                                                • A list of module alias configurations or an object which maps key to value

                                                                                                                                property aliasFields

                                                                                                                                aliasFields?: (string | string[])[];
                                                                                                                                • A list of alias fields in description files

                                                                                                                                property cachePredicate

                                                                                                                                cachePredicate?: (predicate: ResolveRequest) => boolean;
                                                                                                                                • A function which decides whether a request should be cached or not. An object is passed with at least path and request properties.

                                                                                                                                property cacheWithContext

                                                                                                                                cacheWithContext?: boolean;
                                                                                                                                • Whether or not the unsafeCache should include request context as part of the cache key.

                                                                                                                                property conditionNames

                                                                                                                                conditionNames?: string[];
                                                                                                                                • A list of exports field condition names.

                                                                                                                                property descriptionFiles

                                                                                                                                descriptionFiles?: string[];
                                                                                                                                • A list of description files to read from

                                                                                                                                property enforceExtension

                                                                                                                                enforceExtension?: boolean;
                                                                                                                                • Enforce that a extension from extensions must be used

                                                                                                                                property exportsFields

                                                                                                                                exportsFields?: (string | string[])[];
                                                                                                                                • A list of exports fields in description files

                                                                                                                                property extensionAlias

                                                                                                                                extensionAlias?: ExtensionAliasOptions;
                                                                                                                                • An object which maps extension to extension aliases

                                                                                                                                property extensions

                                                                                                                                extensions?: string[];
                                                                                                                                • A list of extensions which should be tried for files

                                                                                                                                property fallback

                                                                                                                                fallback?: AliasOptions | AliasOption[];
                                                                                                                                • A list of module alias configurations or an object which maps key to value, applied only after modules option

                                                                                                                                property fileSystem

                                                                                                                                fileSystem: FileSystem;
                                                                                                                                • The file system which should be used

                                                                                                                                property fullySpecified

                                                                                                                                fullySpecified?: boolean;
                                                                                                                                • The request is already fully specified and no extensions or directories are resolved for it

                                                                                                                                property importsFields

                                                                                                                                importsFields?: (string | string[])[];
                                                                                                                                • A list of imports fields in description files

                                                                                                                                property mainFields

                                                                                                                                mainFields?: (
                                                                                                                                | string
                                                                                                                                | string[]
                                                                                                                                | { name: string | string[]; forceRelative: boolean }
                                                                                                                                )[];
                                                                                                                                • A list of main fields in description files

                                                                                                                                property mainFiles

                                                                                                                                mainFiles?: string[];
                                                                                                                                • A list of main files in directories

                                                                                                                                property modules

                                                                                                                                modules?: string | string[];
                                                                                                                                • A list of directories to resolve modules from, can be absolute path or folder name

                                                                                                                                property plugins

                                                                                                                                plugins?: Plugin[];
                                                                                                                                • A list of additional resolve plugins which should be applied

                                                                                                                                property pnpApi

                                                                                                                                pnpApi?: null | PnpApi;
                                                                                                                                • A PnP API that should be used - null is "never", undefined is "auto"

                                                                                                                                property preferAbsolute

                                                                                                                                preferAbsolute?: boolean;
                                                                                                                                • Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots

                                                                                                                                property preferRelative

                                                                                                                                preferRelative?: boolean;
                                                                                                                                • Prefer to resolve module requests as relative requests before falling back to modules

                                                                                                                                property resolver

                                                                                                                                resolver?: Resolver;
                                                                                                                                • A prepared Resolver to which the plugins are attached

                                                                                                                                property resolveToContext

                                                                                                                                resolveToContext?: boolean;
                                                                                                                                • Resolve to a context instead of a file

                                                                                                                                property restrictions

                                                                                                                                restrictions?: (string | RegExp)[];
                                                                                                                                • A list of resolve restrictions

                                                                                                                                property roots

                                                                                                                                roots?: string[];
                                                                                                                                • A list of root paths

                                                                                                                                symlinks?: boolean;
                                                                                                                                • Resolve symlinks to their symlinked location

                                                                                                                                property tsconfig

                                                                                                                                tsconfig?: string | boolean | TsconfigOptions;
                                                                                                                                • TypeScript config file path or config object with configFile and references

                                                                                                                                property unsafeCache

                                                                                                                                unsafeCache?: boolean | Cache;
                                                                                                                                • Use this cache object to unsafely cache the successful requests

                                                                                                                                property useSyncFileSystemCalls

                                                                                                                                useSyncFileSystemCalls?: boolean;
                                                                                                                                • Use only the sync constraints of the file system calls

                                                                                                                                interface SyncFileSystem

                                                                                                                                interface SyncFileSystem {}

                                                                                                                                  property lstatSync

                                                                                                                                  lstatSync?: LStatSync;
                                                                                                                                  • lstat sync method

                                                                                                                                  property readdirSync

                                                                                                                                  readdirSync: ReaddirSync;
                                                                                                                                  • read dir sync method

                                                                                                                                  property readFileSync

                                                                                                                                  readFileSync: ReadFileSync;
                                                                                                                                  • read file sync method

                                                                                                                                  property readJsonSync

                                                                                                                                  readJsonSync?: (pathOrFileDescription: PathOrFileDescriptor) => JsonObject;
                                                                                                                                  • read json sync method

                                                                                                                                  property readlinkSync

                                                                                                                                  readlinkSync: ReadlinkSync;
                                                                                                                                  • read link sync method

                                                                                                                                  property realpathSync

                                                                                                                                  realpathSync?: RealPathSync;
                                                                                                                                  • real path sync method

                                                                                                                                  property statSync

                                                                                                                                  statSync: StatSync;
                                                                                                                                  • stat sync method

                                                                                                                                  Type Aliases

                                                                                                                                  type BaseFileSystem

                                                                                                                                  type BaseFileSystem = FileSystem & SyncFileSystem;

                                                                                                                                    type Context

                                                                                                                                    type Context = KnownContext & Record<any, any>;

                                                                                                                                      type Plugin

                                                                                                                                      type Plugin =
                                                                                                                                      | undefined
                                                                                                                                      | null
                                                                                                                                      | false
                                                                                                                                      | ''
                                                                                                                                      | 0
                                                                                                                                      | { apply: (this: Resolver, resolver: Resolver) => void }
                                                                                                                                      | ((this: Resolver, resolver: Resolver) => void);

                                                                                                                                        type ResolveCallback

                                                                                                                                        type ResolveCallback = (
                                                                                                                                        err: null | ErrorWithDetail,
                                                                                                                                        res?: string | false,
                                                                                                                                        req?: ResolveRequest
                                                                                                                                        ) => void;

                                                                                                                                          type ResolveOptionsOptionalFS

                                                                                                                                          type ResolveOptionsOptionalFS = Omit<
                                                                                                                                          ResolveOptionsResolverFactoryObject_2,
                                                                                                                                          'fileSystem'
                                                                                                                                          > &
                                                                                                                                          Partial<Pick<ResolveOptionsResolverFactoryObject_2, 'fileSystem'>>;

                                                                                                                                            type ResolveRequest

                                                                                                                                            type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;

                                                                                                                                              Namespaces

                                                                                                                                              namespace create

                                                                                                                                              namespace create {}

                                                                                                                                                function sync

                                                                                                                                                sync: (options: ResolveOptionsOptionalFS) => ResolveFunction;

                                                                                                                                                  namespace ResolverFactory

                                                                                                                                                  namespace ResolverFactory {}

                                                                                                                                                    function createResolver

                                                                                                                                                    createResolver: (options: ResolveOptionsResolverFactoryObject_2) => Resolver;

                                                                                                                                                      Package Files (1)

                                                                                                                                                      Dependencies (2)

                                                                                                                                                      Dev Dependencies (14)

                                                                                                                                                      Peer Dependencies (0)

                                                                                                                                                      No peer dependencies.

                                                                                                                                                      Badge

                                                                                                                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/enhanced-resolve.

                                                                                                                                                      • Markdown
                                                                                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/enhanced-resolve)
                                                                                                                                                      • HTML
                                                                                                                                                        <a href="https://www.jsdocs.io/package/enhanced-resolve"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>