hoist the deprecate function

This commit is contained in:
Tobias Koppers 2019-11-15 10:10:26 +01:00
parent 74074a9b18
commit ba90a1d20e
1 changed files with 15 additions and 9 deletions

View File

@ -9,6 +9,15 @@ const util = require("util");
const ExternalModule = require("./ExternalModule");
const UNSPECIFIED_EXTERNAL_TYPE_REGEXP = /^[a-z0-9]+ /;
// TODO webpack 6 remove this
const callDeprecatedExternals = util.deprecate(
(externalsFunction, context, request, cb) => {
externalsFunction.call(null, context, request, cb);
},
"The externals-function should be defined like ({context, request}, cb) => { ... }",
"DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS"
);
class ExternalModuleFactoryPlugin {
constructor(type, externals) {
this.type = type;
@ -106,15 +115,12 @@ class ExternalModuleFactoryPlugin {
};
if (externals.length === 3) {
// TODO webpack 6 remove this
util
.deprecate(
(context, request, cb) => {
externals.call(null, context, dependency.request, cb);
},
"The externals-function should be defined like ({context, request}, cb) => { ... }",
"DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS"
)
.call(null, context, dependency.request, cb);
callDeprecatedExternals(
externals,
context,
dependency.request,
cb
);
} else {
externals(
{