chore: fix types for nodeExternals

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2021-04-15 09:45:37 +02:00
parent e1f2688c63
commit fcb8cfa7b9
3 changed files with 64 additions and 8 deletions
-1
View File
@@ -52,7 +52,6 @@
"@svgr/webpack": "5.5.x",
"@types/start-server-webpack-plugin": "^2.2.0",
"@types/webpack-env": "^1.15.2",
"@types/webpack-node-externals": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^v4.28.3",
"@typescript-eslint/parser": "^v4.28.3",
"@yarnpkg/lockfile": "^1.1.0",
+64
View File
@@ -31,3 +31,67 @@ declare module '@svgr/rollup' {
declare module '@rollup/plugin-yaml';
declare module 'terser-webpack-plugin';
declare module 'webpack-node-externals' {
export default function webpackNodeExternals(
options?: webpackNodeExternals.Options,
): any;
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[];
include?: string | string[];
}
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;
/**
* @default ['.bin']
*/
binaryDirs?: string[];
/**
* 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'
| ImportTypeCallback;
/**
* The folder in which to search for the node modules.
* @default 'node_modules'
*/
modulesDir?: string;
/**
* Additional folders to look for node modules.
*/
additionalModuleDirs?: string[];
/**
* Read the modules from the package.json file instead of the node_modules folder.
* @default false
*/
modulesFromFile?: boolean | ModulesFromFileType;
/**
* @default false
*/
includeAbsolutePaths?: boolean;
}
}
}