How to use ContextReplacementPlugin on a looped request

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?

+8
webpack
source share

No one has answered this question yet.

See related questions:

135
Resolution requires paths using webpack
4
Error loading module
3
Importing UMD module using webpack leads to critical dependency errors
one
React - export web packages
0
Webpack error: reading is not a function
0
Webpack does not resolve host-resque dependency
0
Error importing local npm package
0
Webpack configuration issue
0
requires webpack with variable trigger webpackMissingModule
0
Enable ContextReplacementPlugin to ignore webpack configuration and test settings

All Articles