I am trying to use ContextReplacementPlugin to resolve dynamic requirements that arise in this for loop: https://github.com/mongodb/js-bson/blob/master/lib/bson/index.js#L7-L24
Here is the code:
[ './binary_parser' , './binary' , './code' , './map' , './db_ref' , './double' , './max_key' , './min_key' , './objectid' , './regexp' , './symbol' , './timestamp' , './long'].forEach(function (path) { var module = require(path); for (var i in module) { exports[i] = module[i]; } });
I am having trouble creating the original regular expression to match this. The path mapped to the source seems to be just a ".". Moreover, the context plugin seems to be called only once, when 13 files are required in this loop. Can ContextReplacementPlugin be used to solve this problem, or do I need to try something else?
webpack
psirenny
source share