{"name":"enhanced-resolve","version":"5.18.0","author":{"name":"Tobias Koppers @sokra"},"description":"Offers a async require.resolve function. It's highly configurable.","browser":{"process":"./lib/util/process-browser.js","module":"./lib/util/module-browser.js"},"dependencies":{"graceful-fs":"^4.2.4","tapable":"^2.2.0"},"license":"MIT","devDependencies":{"@types/graceful-fs":"^4.1.6","@types/jest":"^27.5.1","@types/node":"20.9.5","cspell":"4.2.8","eslint":"^7.9.0","eslint-config-prettier":"^6.11.0","eslint-plugin-jsdoc":"^30.5.1","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.1.4","husky":"^6.0.0","jest":"^27.5.1","lint-staged":"^10.4.0","memfs":"^3.2.0","prettier":"^2.1.2","tooling":"github:webpack/tooling#v1.23.1","typescript":"^5.3.3"},"engines":{"node":">=10.13.0"},"main":"lib/index.js","types":"types.d.ts","homepage":"http://github.com/webpack/enhanced-resolve","scripts":{"lint":"yarn run code-lint && yarn run type-lint && yarn typings-test && yarn run special-lint && yarn run spelling","fix":"yarn run code-lint-fix && yarn run special-lint-fix","code-lint":"eslint --cache lib test","code-lint-fix":"eslint --cache lib test --fix","type-lint":"tsc","typings-test":"tsc -p tsconfig.types.test.json","type-report":"rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html","special-lint":"node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types","special-lint-fix":"node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write","pretty":"prettier --loglevel warn --write \"lib/**/*.{js,json}\" \"test/*.js\"","pretest":"yarn lint","spelling":"cspell \"**\"","test:only":"jest","test:watch":"yarn test:only -- --watch","test:coverage":"yarn test:only -- --collectCoverageFrom=\"lib/**/*.js\" --coverage","test":"yarn test:coverage","precover":"yarn lint","prepare":"husky install"},"lint-staged":{"*":"cspell --no-must-find-files","*.js":"eslint --cache"},"repository":{"type":"git","url":"git://github.com/webpack/enhanced-resolve.git"},"gitHead":"27e457a905776154c9c0f75bc0f822eeab36d2c8","bugs":{"url":"https://github.com/webpack/enhanced-resolve/issues"},"_id":"enhanced-resolve@5.18.0","_nodeVersion":"22.11.0","_npmVersion":"9.6.0","dist":{"integrity":"sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ==","shasum":"91eb1db193896b9801251eeff1c6980278b1e404","tarball":"http://registry-npm.ywwl.com/enhanced-resolve/download/enhanced-resolve-5.18.0.tgz","fileCount":48,"unpackedSize":212397,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlxlOazzCf6kD/Qs91n/srZtgjDkaezE8zpCeV7KpheQIgHx6E21G8g87DhV49VuYtALAsDICIfwAMeQk3A6aWoXM="}],"size":40844,"noattachment":false,"key":"/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz"},"_npmUser":{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/enhanced-resolve_5.18.0_1734701391982_0.08493791991663047"},"_hasShrinkwrap":false,"readme":"# enhanced-resolve\n\n[![npm][npm]][npm-url]\n[![Build Status][build-status]][build-status-url]\n[![codecov][codecov-badge]][codecov-url]\n[![Install Size][size]][size-url]\n[![GitHub Discussions][discussion]][discussion-url]\n\nOffers an async require.resolve function. It's highly configurable.\n\n## Features\n\n- plugin system\n- provide a custom filesystem\n- sync and async node.js filesystems included\n\n## Getting Started\n\n### Install\n\n```sh\n# npm\nnpm install enhanced-resolve\n# or Yarn\nyarn add enhanced-resolve\n```\n\n### Resolve\n\nThere is a Node.js API which allows to resolve requests according to the Node.js resolving rules.\nSync and async APIs are offered. A `create` method allows to create a custom resolve function.\n\n```js\nconst resolve = require(\"enhanced-resolve\");\n\nresolve(\"/some/path/to/folder\", \"module/dir\", (err, result) => {\n\tresult; // === \"/some/path/node_modules/module/dir/index.js\"\n});\n\nresolve.sync(\"/some/path/to/folder\", \"../../dir\");\n// === \"/some/path/dir/index.js\"\n\nconst myResolve = resolve.create({\n\t// or resolve.create.sync\n\textensions: [\".ts\", \".js\"]\n\t// see more options below\n});\n\nmyResolve(\"/some/path/to/folder\", \"ts-module\", (err, result) => {\n\tresult; // === \"/some/node_modules/ts-module/index.ts\"\n});\n```\n\n### Creating a Resolver\n\nThe easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations.\n\n```js\nconst fs = require(\"fs\");\nconst { CachedInputFileSystem, ResolverFactory } = require(\"enhanced-resolve\");\n\n// create a resolver\nconst myResolver = ResolverFactory.createResolver({\n\t// Typical usage will consume the `fs` + `CachedInputFileSystem`, which wraps Node.js `fs` to add caching.\n\tfileSystem: new CachedInputFileSystem(fs, 4000),\n\textensions: [\".js\", \".json\"]\n\t/* any other resolver options here. Options/defaults can be seen below */\n});\n\n// resolve a file with the new resolver\nconst context = {};\nconst lookupStartPath = \"/Users/webpack/some/root/dir\";\nconst request = \"./path/to-look-up.js\";\nconst resolveContext = {};\nmyResolver.resolve(context, lookupStartPath, request, resolveContext, (\n\terr /*Error*/,\n\tfilepath /*string*/\n) => {\n\t// Do something with the path\n});\n```\n\n#### Resolver Options\n\n| Field            | Default                     | Description                                                                                                                                               |\n|------------------|-----------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| alias            | []                          | A list of module alias configurations or an object which maps key to value                                                                                |\n| aliasFields      | []                          | A list of alias fields in description files                                                                                                               |\n| extensionAlias   | {}                          | An object which maps extension to extension aliases                                                                                                       |\n| cachePredicate   | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties.             |\n| cacheWithContext | true                        | If unsafe cache is enabled, includes `request.context` in the cache key                                                                                   |\n| conditionNames   | []                          | A list of exports field condition names                                                                                                                   |\n| descriptionFiles | [\"package.json\"]            | A list of description files to read from                                                                                                                  |\n| enforceExtension | false                       | Enforce that a extension from extensions must be used                                                                                                     |\n| exportsFields    | [\"exports\"]                 | A list of exports fields in description files                                                                                                             |\n| extensions       | [\".js\", \".json\", \".node\"]   | A list of extensions which should be tried for files                                                                                                      |\n| fallback         | []                          | Same as `alias`, but only used if default resolving fails                                                                                                |                                                                                                                                                                                         \n| fileSystem       |                             | The file system which should be used                                                                                                                      |\n| fullySpecified   | false                       | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) |\n| mainFields       | [\"main\"]                    | A list of main fields in description files                                                                                                                |\n| mainFiles        | [\"index\"]                   | A list of main files in directories                                                                                                                       |\n| modules          | [\"node_modules\"]            | A list of directories to resolve modules from, can be absolute path or folder name                                                                        |\n| plugins          | []                          | A list of additional resolve plugins which should be applied                                                                                              |\n| resolver         | undefined                   | A prepared Resolver to which the plugins are attached                                                                                                     |\n| resolveToContext | false                       | Resolve to a context instead of a file                                                                                                                    |\n| preferRelative   | false                       | Prefer to resolve module requests as relative request and fallback to resolving as module                                                                 |\n| preferAbsolute   | false                       | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots                                                          |\n| restrictions     | []                          | A list of resolve restrictions                                                                                                                            |\n| roots            | []                          | A list of root paths                                                                                                                                      |\n| symlinks         | true                        | Whether to resolve symlinks to their symlinked location                                                                                                   |\n| unsafeCache      | false                       | Use this cache object to unsafely cache the successful requests                                                                                           |\n\n## Plugins\n\nSimilar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`tapable`](https://github.com/webpack/tapable).\nThese plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.\n\nA plugin should be a `class` (or its ES5 equivalent) with an `apply` method. The `apply` method will receive a `resolver` instance, that can be used to hook in to the event system.\n\n### Plugin Boilerplate\n\n```js\nclass MyResolverPlugin {\n\tconstructor(source, target) {\n\t\tthis.source = source;\n\t\tthis.target = target;\n\t}\n\n\tapply(resolver) {\n\t\tconst target = resolver.ensureHook(this.target);\n\t\tresolver\n\t\t\t.getHook(this.source)\n\t\t\t.tapAsync(\"MyResolverPlugin\", (request, resolveContext, callback) => {\n\t\t\t\t// Any logic you need to create a new `request` can go here\n\t\t\t\tresolver.doResolve(target, request, null, resolveContext, callback);\n\t\t\t});\n\t}\n}\n```\n\nPlugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, `source` is the name of the event that starts the pipeline, and `target` is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see `lib/ResolverFactory.js`, in the `//// pipeline ////` section.\n\n## Escaping\n\nIt's allowed to escape `#` as `\\0#` to avoid parsing it as fragment.\n\nenhanced-resolve will try to resolve requests containing `#` as path and as fragment, so it will automatically figure out if `./some#thing` means `.../some.js#thing` or `.../some#thing.js`. When a `#` is resolved as path it will be escaped in the result. Here: `.../some\\0#thing.js`.\n\n## Tests\n\n```javascript\nyarn test\n```\n\n## Passing options from webpack\n\nIf you are using `webpack`, and you want to pass custom options to `enhanced-resolve`, the options are passed from the `resolve` key of your webpack configuration e.g.:\n\n```\nresolve: {\n  extensions: ['.js', '.jsx'],\n  modules: [path.resolve(__dirname, 'src'), 'node_modules'],\n  plugins: [new DirectoryNamedWebpackPlugin()]\n  ...\n},\n```\n\n## License\n\nCopyright (c) 2012-2019 JS Foundation and other contributors\n\nMIT (http://www.opensource.org/licenses/mit-license.php)\n\n[npm]: https://img.shields.io/npm/v/enhanced-resolve.svg\n[npm-url]: https://www.npmjs.com/package/enhanced-resolve\n[build-status]: https://github.com/webpack/enhanced-resolve/actions/workflows/test.yml/badge.svg?branch=master\n[build-status-url]: https://github.com/webpack/enhanced-resolve/actions\n[codecov-badge]: https://codecov.io/gh/webpack/enhanced-resolve/branch/main/graph/badge.svg?token=6B6NxtsZc3\n[codecov-url]: https://codecov.io/gh/webpack/enhanced-resolve\n[size]: https://packagephobia.com/badge?p=enhanced-resolve\n[size-url]: https://packagephobia.com/result?p=enhanced-resolve\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n","publish_time":1734701392156,"maintainers":[{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"jhnns","email":"mail@johannesewald.de"},{"name":"thelarkinn","email":"sean.larkin1@gmail.com"},{"name":"evilebottnawi","email":"sheo13666q@gmail.com"}],"_cnpm_publish_time":1734701392156,"dist-tags":{"beta":"5.0.0-beta.12","enhanced-resolve-4":"4.5.0","latest":"5.27.0"}}