This commit is contained in:
Tutur33
2023-11-24 23:58:26 +01:00
parent 25395c0ee1
commit 938ad9d309
4191 changed files with 41 additions and 518781 deletions
-20
View File
@@ -1,20 +0,0 @@
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-183
View File
@@ -1,183 +0,0 @@
# enhanced-resolve
[![npm][npm]][npm-url]
[![Build Status][build-status]][build-status-url]
[![codecov][codecov-badge]][codecov-url]
[![Install Size][size]][size-url]
[![GitHub Discussions][discussion]][discussion-url]
Offers an async require.resolve function. It's highly configurable.
## Features
- plugin system
- provide a custom filesystem
- sync and async node.js filesystems included
## Getting Started
### Install
```sh
# npm
npm install enhanced-resolve
# or Yarn
yarn add enhanced-resolve
```
### Resolve
There is a Node.js API which allows to resolve requests according to the Node.js resolving rules.
Sync and async APIs are offered. A `create` method allows to create a custom resolve function.
```js
const resolve = require("enhanced-resolve");
resolve("/some/path/to/folder", "module/dir", (err, result) => {
result; // === "/some/path/node_modules/module/dir/index.js"
});
resolve.sync("/some/path/to/folder", "../../dir");
// === "/some/path/dir/index.js"
const myResolve = resolve.create({
// or resolve.create.sync
extensions: [".ts", ".js"]
// see more options below
});
myResolve("/some/path/to/folder", "ts-module", (err, result) => {
result; // === "/some/node_modules/ts-module/index.ts"
});
```
### Creating a Resolver
The easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations.
```js
const fs = require("fs");
const { CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve");
// create a resolver
const myResolver = ResolverFactory.createResolver({
// Typical usage will consume the `fs` + `CachedInputFileSystem`, which wraps Node.js `fs` to add caching.
fileSystem: new CachedInputFileSystem(fs, 4000),
extensions: [".js", ".json"]
/* any other resolver options here. Options/defaults can be seen below */
});
// resolve a file with the new resolver
const context = {};
const lookupStartPath = "/Users/webpack/some/root/dir";
const request = "./path/to-look-up.js";
const resolveContext = {};
myResolver.resolve(context, lookupStartPath, request, resolveContext, (
err /*Error*/,
filepath /*string*/
) => {
// Do something with the path
});
```
#### Resolver Options
| Field | Default | Description |
|------------------|-----------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | [] | A list of module alias configurations or an object which maps key to value |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
| 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. |
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
| conditionNames | [] | A list of exports field condition names |
| descriptionFiles | ["package.json"] | A list of description files to read from |
| enforceExtension | false | Enforce that a extension from extensions must be used |
| exportsFields | ["exports"] | A list of exports fields in description files |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| fallback | [] | Same as `alias`, but only used if default resolving fails |
| fileSystem | | The file system which should be used |
| 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) |
| mainFields | ["main"] | A list of main fields in description files |
| mainFiles | ["index"] | A list of main files in directories |
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
| plugins | [] | A list of additional resolve plugins which should be applied |
| resolver | undefined | A prepared Resolver to which the plugins are attached |
| resolveToContext | false | Resolve to a context instead of a file |
| preferRelative | false | Prefer to resolve module requests as relative request and fallback to resolving as module |
| preferAbsolute | false | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots |
| restrictions | [] | A list of resolve restrictions |
| roots | [] | A list of root paths |
| symlinks | true | Whether to resolve symlinks to their symlinked location |
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
## Plugins
Similar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`tapable`](https://github.com/webpack/tapable).
These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.
A 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.
### Plugin Boilerplate
```js
class MyResolverPlugin {
constructor(source, target) {
this.source = source;
this.target = target;
}
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver
.getHook(this.source)
.tapAsync("MyResolverPlugin", (request, resolveContext, callback) => {
// Any logic you need to create a new `request` can go here
resolver.doResolve(target, request, null, resolveContext, callback);
});
}
}
```
Plugins 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.
## Escaping
It's allowed to escape `#` as `\0#` to avoid parsing it as fragment.
enhanced-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`.
## Tests
```javascript
yarn test
```
## Passing options from webpack
If 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.:
```
resolve: {
extensions: ['.js', '.jsx'],
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
plugins: [new DirectoryNamedWebpackPlugin()]
...
},
```
## License
Copyright (c) 2012-2019 JS Foundation and other contributors
MIT (http://www.opensource.org/licenses/mit-license.php)
[npm]: https://img.shields.io/npm/v/enhanced-resolve.svg
[npm-url]: https://www.npmjs.com/package/enhanced-resolve
[build-status]: https://github.com/webpack/enhanced-resolve/actions/workflows/test.yml/badge.svg?branch=master
[build-status-url]: https://github.com/webpack/enhanced-resolve/actions
[codecov-badge]: https://codecov.io/gh/webpack/enhanced-resolve/branch/main/graph/badge.svg?token=6B6NxtsZc3
[codecov-url]: https://codecov.io/gh/webpack/enhanced-resolve
[size]: https://packagephobia.com/badge?p=enhanced-resolve
[size-url]: https://packagephobia.com/result?p=enhanced-resolve
[discussion]: https://img.shields.io/github/discussions/webpack/webpack
[discussion-url]: https://github.com/webpack/webpack/discussions
-72
View File
@@ -1,72 +0,0 @@
{
"name": "enhanced-resolve",
"version": "5.15.0",
"author": "Tobias Koppers @sokra",
"description": "Offers a async require.resolve function. It's highly configurable.",
"files": [
"lib",
"types.d.ts",
"LICENSE"
],
"browser": {
"pnpapi": false,
"process": "./lib/util/process-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": "^14.11.1",
"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": "webpack/tooling#v1.14.0",
"typescript": "^5.0.4"
},
"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"
}
}
-712
View File
@@ -1,712 +0,0 @@
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn special-lint-fix` to update
*/
import { Dirent } from "fs";
import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable";
type Alias = string | false | string[];
declare interface AliasOption {
alias: Alias;
name: string;
onlyModule?: boolean;
}
type AliasOptionNewRequest = string | false | string[];
declare interface AliasOptions {
[index: string]: AliasOptionNewRequest;
}
declare interface BaseResolveRequest {
path: string | false;
context?: object;
descriptionFilePath?: string;
descriptionFileRoot?: string;
descriptionFileData?: JsonObject;
relativePath?: string;
ignoreSymlinks?: boolean;
fullySpecified?: boolean;
__innerRequest?: string;
__innerRequest_request?: string;
__innerRequest_relativePath?: string;
}
declare class CachedInputFileSystem {
constructor(fileSystem: any, duration: number);
fileSystem: any;
lstat?: {
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
lstatSync?: (arg0: string, arg1?: object) => FileSystemStats;
stat: {
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
statSync: (arg0: string, arg1?: object) => FileSystemStats;
readdir: (
arg0: string,
arg1?:
| null
| ((
arg0?: null | NodeJS.ErrnoException,
arg1?: (string | Buffer)[] | Dirent[]
) => void)
| ReaddirOptions
| "ascii"
| "utf8"
| "utf-8"
| "utf16le"
| "ucs2"
| "ucs-2"
| "base64"
| "base64url"
| "latin1"
| "binary"
| "hex"
| "buffer",
arg2?: (
arg0?: null | NodeJS.ErrnoException,
arg1?: (string | Buffer)[] | Dirent[]
) => void
) => void;
readdirSync: (
arg0: string,
arg1?: object
) => (string | Buffer)[] | FileSystemDirent[];
readFile: {
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
readFileSync: (arg0: string, arg1?: object) => string | Buffer;
readJson?: {
(arg0: string, arg1: FileSystemCallback<object>): void;
(arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
};
readJsonSync?: (arg0: string, arg1?: object) => object;
readlink: {
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
readlinkSync: (arg0: string, arg1?: object) => string | Buffer;
purge(what?: string | Set<string> | string[]): void;
}
declare class CloneBasenamePlugin {
constructor(
source:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>,
target:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>
);
source:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
target:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
apply(resolver: Resolver): void;
}
type ErrorWithDetail = Error & { details?: string };
declare interface ExtensionAliasOption {
alias: string | string[];
extension: string;
}
declare interface ExtensionAliasOptions {
[index: string]: string | string[];
}
declare interface FileSystem {
readFile: {
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
readdir: (
arg0: string,
arg1?:
| null
| ((
arg0?: null | NodeJS.ErrnoException,
arg1?: (string | Buffer)[] | Dirent[]
) => void)
| ReaddirOptions
| "ascii"
| "utf8"
| "utf-8"
| "utf16le"
| "ucs2"
| "ucs-2"
| "base64"
| "base64url"
| "latin1"
| "binary"
| "hex"
| "buffer",
arg2?: (
arg0?: null | NodeJS.ErrnoException,
arg1?: (string | Buffer)[] | Dirent[]
) => void
) => void;
readJson?: {
(arg0: string, arg1: FileSystemCallback<object>): void;
(arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
};
readlink: {
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
lstat?: {
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
stat: {
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
(
arg0: string,
arg1: object,
arg2: FileSystemCallback<string | Buffer>
): void;
};
}
declare interface FileSystemCallback<T> {
(err?: null | (PossibleFileSystemError & Error), result?: T): any;
}
declare interface FileSystemDirent {
name: string | Buffer;
isDirectory: () => boolean;
isFile: () => boolean;
}
declare interface FileSystemStats {
isDirectory: () => boolean;
isFile: () => boolean;
}
declare interface Iterator<T, Z> {
(
item: T,
callback: (err?: null | Error, result?: null | Z) => void,
i: number
): void;
}
type JsonObject = { [index: string]: JsonValue } & {
[index: string]:
| undefined
| null
| string
| number
| boolean
| JsonObject
| JsonValue[];
};
type JsonValue = null | string | number | boolean | JsonObject | JsonValue[];
declare interface KnownHooks {
resolveStep: SyncHook<
[
AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>,
ResolveRequest
]
>;
noResolve: SyncHook<[ResolveRequest, Error]>;
resolve: AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
}
declare class LogInfoPlugin {
constructor(
source:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>
);
source:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
apply(resolver: Resolver): void;
}
declare interface ParsedIdentifier {
request: string;
query: string;
fragment: string;
directory: boolean;
module: boolean;
file: boolean;
internal: boolean;
}
type Plugin =
| undefined
| null
| false
| ""
| 0
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void);
declare interface PnpApiImpl {
resolveToUnqualified: (arg0: string, arg1: string, arg2: object) => string;
}
declare interface PossibleFileSystemError {
code?: string;
errno?: number;
path?: string;
syscall?: string;
}
declare interface ReaddirOptions {
encoding?:
| null
| "ascii"
| "utf8"
| "utf-8"
| "utf16le"
| "ucs2"
| "ucs-2"
| "base64"
| "base64url"
| "latin1"
| "binary"
| "hex"
| "buffer";
withFileTypes?: boolean;
}
/**
* Resolve context
*/
declare interface ResolveContext {
contextDependencies?: WriteOnlySet<string>;
/**
* files that was found on file system
*/
fileDependencies?: WriteOnlySet<string>;
/**
* dependencies that was not found on file system
*/
missingDependencies?: WriteOnlySet<string>;
/**
* set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
*/
stack?: Set<string>;
/**
* log function
*/
log?: (arg0: string) => void;
/**
* yield result, if provided plugins can return several results
*/
yield?: (arg0: ResolveRequest) => void;
}
declare interface ResolveFunction {
(context: object, path: string, request: string): string | false;
(path: string, request: string): string | false;
}
declare interface ResolveFunctionAsync {
(
context: object,
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
(
context: object,
path: string,
request: string,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
(
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
(
path: string,
request: string,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
}
declare interface ResolveOptions {
alias: AliasOption[];
fallback: AliasOption[];
aliasFields: Set<string | string[]>;
extensionAlias: ExtensionAliasOption[];
cachePredicate: (arg0: ResolveRequest) => boolean;
cacheWithContext: boolean;
/**
* A list of exports field condition names.
*/
conditionNames: Set<string>;
descriptionFiles: string[];
enforceExtension: boolean;
exportsFields: Set<string | string[]>;
importsFields: Set<string | string[]>;
extensions: Set<string>;
fileSystem: FileSystem;
unsafeCache: false | object;
symlinks: boolean;
resolver?: Resolver;
modules: (string | string[])[];
mainFields: { name: string[]; forceRelative: boolean }[];
mainFiles: Set<string>;
plugins: Plugin[];
pnpApi: null | PnpApiImpl;
roots: Set<string>;
fullySpecified: boolean;
resolveToContext: boolean;
restrictions: Set<string | RegExp>;
preferRelative: boolean;
preferAbsolute: boolean;
}
type ResolveOptionsOptionalFS = Omit<UserResolveOptions, "fileSystem"> &
Partial<Pick<UserResolveOptions, "fileSystem">>;
type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
declare abstract class Resolver {
fileSystem: FileSystem;
options: ResolveOptions;
hooks: KnownHooks;
ensureHook(
name:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>
): AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
getHook(
name:
| string
| AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>
): AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>;
resolveSync(context: object, path: string, request: string): string | false;
resolve(
context: object,
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
doResolve(
hook: AsyncSeriesBailHook<
[ResolveRequest, ResolveContext],
null | ResolveRequest
>,
request: ResolveRequest,
message: null | string,
resolveContext: ResolveContext,
callback: (err?: null | Error, result?: ResolveRequest) => void
): void;
parse(identifier: string): ParsedIdentifier;
isModule(path: string): boolean;
isPrivate(path: string): boolean;
isDirectory(path: string): boolean;
join(path: string, request: string): string;
normalize(path: string): string;
}
declare interface UserResolveOptions {
/**
* A list of module alias configurations or an object which maps key to value
*/
alias?: AliasOptions | AliasOption[];
/**
* A list of module alias configurations or an object which maps key to value, applied only after modules option
*/
fallback?: AliasOptions | AliasOption[];
/**
* An object which maps extension to extension aliases
*/
extensionAlias?: ExtensionAliasOptions;
/**
* A list of alias fields in description files
*/
aliasFields?: (string | string[])[];
/**
* A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
*/
cachePredicate?: (arg0: ResolveRequest) => boolean;
/**
* Whether or not the unsafeCache should include request context as part of the cache key.
*/
cacheWithContext?: boolean;
/**
* A list of description files to read from
*/
descriptionFiles?: string[];
/**
* A list of exports field condition names.
*/
conditionNames?: string[];
/**
* Enforce that a extension from extensions must be used
*/
enforceExtension?: boolean;
/**
* A list of exports fields in description files
*/
exportsFields?: (string | string[])[];
/**
* A list of imports fields in description files
*/
importsFields?: (string | string[])[];
/**
* A list of extensions which should be tried for files
*/
extensions?: string[];
/**
* The file system which should be used
*/
fileSystem: FileSystem;
/**
* Use this cache object to unsafely cache the successful requests
*/
unsafeCache?: boolean | object;
/**
* Resolve symlinks to their symlinked location
*/
symlinks?: boolean;
/**
* A prepared Resolver to which the plugins are attached
*/
resolver?: Resolver;
/**
* A list of directories to resolve modules from, can be absolute path or folder name
*/
modules?: string | string[];
/**
* A list of main fields in description files
*/
mainFields?: (
| string
| string[]
| { name: string | string[]; forceRelative: boolean }
)[];
/**
* A list of main files in directories
*/
mainFiles?: string[];
/**
* A list of additional resolve plugins which should be applied
*/
plugins?: Plugin[];
/**
* A PnP API that should be used - null is "never", undefined is "auto"
*/
pnpApi?: null | PnpApiImpl;
/**
* A list of root paths
*/
roots?: string[];
/**
* The request is already fully specified and no extensions or directories are resolved for it
*/
fullySpecified?: boolean;
/**
* Resolve to a context instead of a file
*/
resolveToContext?: boolean;
/**
* A list of resolve restrictions
*/
restrictions?: (string | RegExp)[];
/**
* Use only the sync constraints of the file system calls
*/
useSyncFileSystemCalls?: boolean;
/**
* Prefer to resolve module requests as relative requests before falling back to modules
*/
preferRelative?: boolean;
/**
* Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
*/
preferAbsolute?: boolean;
}
declare interface WriteOnlySet<T> {
add: (item: T) => void;
}
declare function exports(
context: object,
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
declare function exports(
context: object,
path: string,
request: string,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
declare function exports(
path: string,
request: string,
resolveContext: ResolveContext,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
declare function exports(
path: string,
request: string,
callback: (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void
): void;
declare namespace exports {
export const sync: ResolveFunction;
export function create(
options: ResolveOptionsOptionalFS
): ResolveFunctionAsync;
export namespace create {
export const sync: (options: ResolveOptionsOptionalFS) => ResolveFunction;
}
export namespace ResolverFactory {
export let createResolver: (options: UserResolveOptions) => Resolver;
}
export const forEachBail: <T, Z>(
array: T[],
iterator: Iterator<T, Z>,
callback: (err?: null | Error, result?: null | Z) => void
) => void;
export type ResolveCallback = (
err: null | ErrorWithDetail,
res?: string | false,
req?: ResolveRequest
) => void;
export {
CachedInputFileSystem,
CloneBasenamePlugin,
LogInfoPlugin,
ResolveOptionsOptionalFS,
PnpApiImpl as PnpApi,
Resolver,
FileSystem,
ResolveContext,
ResolveRequest,
Plugin,
UserResolveOptions as ResolveOptions,
ResolveFunctionAsync,
ResolveFunction
};
}
export = exports;