I would like to require a list of requirements in webpack. As soon as I replace the string parameter of the require function with a variable or constant, it can no longer make this requirement.
Here is a great working example:
const angular = require('angular');
But as soon as I change this to the following, it no longer works:
const angularString = 'angular'; const angular = require(angularString);
My goal is to have a static list of dependencies and introduce them one by one, for example:
const angularDependencies = [ 'angular-socket-io', 'angular-ui-router' ]; for(var i = 0; i < angularDependencies.length; i++) { require(angularDependencies[i]); }
This is the error message I received:
WARNING in ./app/app.js Critical dependencies: 14:1-14 the request of a dependency is an expression @ ./app/app.js 14:1-14 WARNING in ./app ^\.\/.*$ Module not found: Error: a dependency to an entry point is not allowed @ ./app ^\.\/.*$ WARNING in ./app ^\.\/.*$ Module not found: Error: a dependency to an entry point is not allowed @ ./app ^\.\/.*$
source share