Usually, if static requirements or import (CommonJS / ES import), webpack can require any module from / node_modules /, for example:
var vendorModule = require('vendor-module');
But I want to dynamically load the module from / node_modules / like:
var vendorModuleId = 'vendor-module';
...
var vendorModule = require(vendorModuleId);
This does not work because webpack cannot determine the dependency at compile time and is obviously insane to include all / node_modules / in the kit if we want to dynamically load some provider module.
I am looking for a way to trick webpack into dynamically solving these modules. Preferably, telling webpack which modules in / node_modules / should be included through the webpack configuration file.
Some people say that ContextReplacementPlugin may be useful for these situations, but I cannot figure out how to do this.
- , ? !