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;
}
}
}
-7
View File
@@ -6969,13 +6969,6 @@
resolved "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.16.0.tgz#8c0a9435dfa7b3b1be76562f3070efb3f92637b4"
integrity sha512-Fx+NpfOO0CpeYX2g9bkvX8O5qh9wrU1sOF4g8sft4Mu7z+qfe387YlyY8w8daDyDsKY5vUxM0yxkAYnbkRbZEw==
"@types/webpack-node-externals@^2.5.0":
version "2.5.2"
resolved "https://registry.npmjs.org/@types/webpack-node-externals/-/webpack-node-externals-2.5.2.tgz#d6e0c90147472304b6b5cfcd1bbd7138e6b9eb65"
integrity sha512-MeNdcLW9Wqtj20057ixY35oFl+m59LlyPCi7GbjkJlf2043SJQg8br/5sQDAiSIIBPi7fqdJ+dVwLvhH5NLZtQ==
dependencies:
"@types/webpack" "^4"
"@types/webpack-sources@*":
version "0.1.6"
resolved "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.6.tgz#3d21dfc2ec0ad0c77758e79362426a9ba7d7cbcb"