My desktop app is using Electron+React for the interface and Edge.js to connect Node with my C# application.
My problem is: Webpack is failing to bundle my application because the Edge.js dependency throws the following error:
Critical dependency: the request of a dependency is an expression
The problem is that Edge.js has the following dynamic require:
var compilerName = 'edge-' + language.toLowerCase();
var compiler = require(compilerName);
Most of the time, compilerName
will be translated to "edge-cs", but Webpack is not able to determine this.
How can I solve this issue? People are suggesting to set the require context or ContextReplacementPlugin, but both of them are usually applied in cases where you have require('./directory/' + variable)
and I don't know how to use them in my case where I have require(variable)
.
Note: I need a solution where I don't need to modify my third-party library code.
I don't think this is possible, Have you considered something like a massive switch below? It is suggested here
switch (name) {
case 'a': return require('./a');
case 'b': return require('./b');
// etc...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With