bump webpack-node-externals to 1.7 (#40493)

* bump to 1.7

* add test for importType and modulesFromFile

* fix header url

* fix missing semicolon & non-arrow function

* replace literal with interface

* fix missing semicolons
This commit is contained in:
Manuel
2019-11-19 20:36:12 +01:00
committed by Sheetal Nandi
parent 8b940b4dba
commit 4b166eac46
2 changed files with 60 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for webpack-node-externals 1.6
// Type definitions for webpack-node-externals 1.7
// Project: https://github.com/liady/webpack-node-externals
// Definitions by: Matt Traynham <https://github.com/mtraynham>
// Manuel Pogge <https://github.com/MrSpoocy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -12,6 +13,12 @@ declare function webpackNodeExternals(options?: webpackNodeExternals.Options): E
declare namespace webpackNodeExternals {
type WhitelistOption = string | RegExp;
type ImportTypeCallback = (moduleName: string) => string;
interface ModulesFromFileType {
exclude?: string | string[];
include?: string | string[];
}
interface Options {
/**
@@ -33,7 +40,7 @@ declare namespace webpackNodeExternals {
* 'commonjs' for node modules.
* @default 'commonjs'
*/
importType?: 'var' | 'this' | 'commonjs' | 'amd' | 'umd';
importType?: 'var' | 'this' | 'commonjs' | 'amd' | 'umd' | ImportTypeCallback;
/**
* The folder in which to search for the node modules.
* @default 'node_modules'
@@ -43,7 +50,7 @@ declare namespace webpackNodeExternals {
* Read the modules from the package.json file instead of the node_modules folder.
* @default false
*/
modulesFromFile?: boolean;
modulesFromFile?: boolean | ModulesFromFileType;
/**
* @default false
*/

View File

@@ -19,3 +19,53 @@ const c: webpack.Configuration = {
})
]
};
const d: webpack.Configuration = {
entry: 'test.js',
externals: [
webpackNodeExternals({
importType: (moduleName) => {
return 'commonjs';
}
})
]
};
const e: webpack.Configuration = {
entry: 'test.js',
externals: [
webpackNodeExternals({
modulesFromFile: {
exclude: 'devDependencies'
}
})
]
};
const f: webpack.Configuration = {
entry: 'test.js',
externals: [
webpackNodeExternals({
modulesFromFile: {
exclude: ['devDependencies']
}
})
]
};
const g: webpack.Configuration = {
entry: 'test.js',
externals: [
webpackNodeExternals({
modulesFromFile: {
include: 'dependencies'
}
})
]
};
const h: webpack.Configuration = {
entry: 'test.js',
externals: [
webpackNodeExternals({
modulesFromFile: {
include: ['dependencies']
}
})
]
};