webpack dynamic module loader by require : <p>OK, i have searched high and low but cannot reliably deterrmine if this is or is not possible with webpack.</p>

<p><a href="https://github.com/webpack/webpack/tree/master/examples/require.context" rel="noreferrer">https://github.com/webpack/webpack/tree/master/examples/require.context</a>
Appears to indicate that one can pass a string to a function and it load a module... </p>

<p>But my attempt is just not working:
webpack.config.js</p>

<pre><code>'use strict';
let webpack     = require('webpack'),
    jsonLoader  = require("json-loader"),
    path        = require("path"),
    fs          = require('fs'),
    nodeModules = {};

fs.readdirSync('node_modules')
    .filter(function(x) {
        return ['.bin'].indexOf(x) === -1;
    })
    .forEach(function(mod) {
        nodeModules[mod] = 'commonjs ' + mod;
    });


let PATHS = {
    app: __dirname + '/src'
};

module.exports = {
    context: PATHS.app,
    entry: {
        app: PATHS.app+'/server.js'
    },
    target: 'node',
    output: {
        path: PATHS.app,
        filename: '../build/server.js'
    },
    externals: nodeModules,
    performance: {
        hints: "warning"
    },
    plugins: [
        jsonLoader
    ],
    resolve: {
        modules: [
            './node_modules',
            path.resolve(__dirname),
            path.resolve(__dirname + "/src"),
            path.resolve('./config')
        ]
    },
    node: {
        fs: "empty"
    }
};
</code></pre>

<p>The server.js</p>

<pre><code>let _ = require('lodash');
let modules = [ "modules/test" ];

require( 'modules/test' )();

_.map( modules, function( module ){
    require( module );
});
</code></pre>

<p>The module in modules/ named test.js</p>

<pre><code>module.exports = () =&gt; {
    console.log('hello world');
};
</code></pre>

<p>But the result is always the same... the pm2 logs just say hello world for the static require... but for the dynamic load of the same module</p>

<blockquote>
  <p>Error: Cannot find module "."</p>
</blockquote>

<p>All i want to be able to do is loop through an array of paths to modules and load then... </p>
