Reputation: 73
Trying to follow this tutorial for using webpack for the backend I have successfully build the bundle, unfortunately on completion it warnsCritical dependency: the request of a dependency is an expression
, I used webpack-node-externals
module to externalize the whole node_modules
directory but I need to dynamically require some modules from node_modules
but webpack replaces my require with an error. Apparently there's a way to tell webpack to leave alone those requires that cannot resolve but it warns webpack: Using compiler.parser is deprecated
, apparently that way of creating an inline plugin has been deprecated but I'm not able to translate that to the new syntax which should be:
compiler.plugin("compilation", function(compilation, params) {
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
parser.plugin(/* ... */);
});
});
According to this. Any help is appreciated.
Upvotes: 1
Views: 298
Reputation: 73
function IgnoreUnresolvedPlugin() { }
IgnoreUnresolvedPlugin.prototype.apply = function (compiler) {
compiler.plugin("compilation", function (compilation, data) {
data.normalModuleFactory.plugin("parser", function (parser) {
parser.plugin('call require', function (params) {
if (params.arguments.length !== 1) { return; }
const param = this.evaluateExpression(params.arguments[0]);
if (!param.isString() && !param.isConditional()) {
return true;
}
});
});
});
};
Upvotes: 1