-
Notifications
You must be signed in to change notification settings - Fork 29.8k
/
index.d.ts
62 lines (57 loc) · 2.46 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/// <reference types="node" />
import { ExternalsPlugin } from "webpack";
export = webpackNodeExternals;
type GetArrayInnerType<T> = T extends Array<infer U> ? U : never;
/** The webpack types don't export this so we have to derive it. */
type ExternalItem = GetArrayInnerType<ExternalsPlugin["externals"]>;
declare function webpackNodeExternals(options?: webpackNodeExternals.Options): ExternalItem;
declare namespace webpackNodeExternals {
type AllowlistOption = string | RegExp | AllowlistFunctionType;
type ImportTypeCallback = (moduleName: string) => string;
/** a function that accepts the module name and returns whether it should be included */
type AllowlistFunctionType = (moduleName: string) => boolean;
interface ModulesFromFileType {
exclude?: string | string[] | undefined;
include?: string | string[] | undefined;
}
interface Options {
/**
* An array for the externals to allow, so they will be included in the bundle.
* Can accept exact strings ('module_name'), regex patterns (/^module_name/), or a
* function that accepts the module name and returns whether it should be included.
* Important - if you have set aliases in your webpack config with the exact
* same names as modules in node_modules, you need to allowlist them so Webpack will know
* they should be bundled.
* @default []
*/
allowlist?: AllowlistOption[] | AllowlistOption | undefined;
/**
* @default ['.bin']
*/
binaryDirs?: string[] | undefined;
/**
* The method in which unbundled modules will be required in the code. Best to leave as
* 'commonjs' for node modules.
* @default 'commonjs'
*/
importType?: "var" | "this" | "commonjs" | "amd" | "umd" | "module" | ImportTypeCallback | undefined;
/**
* The folder in which to search for the node modules.
* @default 'node_modules'
*/
modulesDir?: string | undefined;
/**
* Additional folders to look for node modules.
*/
additionalModuleDirs?: string[] | undefined;
/**
* Read the modules from the package.json file instead of the node_modules folder.
* @default false
*/
modulesFromFile?: boolean | ModulesFromFileType | undefined;
/**
* @default false
*/
includeAbsolutePaths?: boolean | undefined;
}
}