liady / webpack-node-externals

Easily exclude node modules in Webpack
MIT License
1.3k stars 62 forks source link

Question about additionalModuleDirs #90

Open therealgilles opened 3 years ago

therealgilles commented 3 years ago

I'm looking at the additionalModuleDirs option to specify additional node_modules locations. I observe the code below:

    additionalModuleDirs.forEach(function (additionalDirectory) {
        console.log('...', additionalDirectory, utils.readDir(additionalDirectory).filter(isNotBinary));
        nodeModules = nodeModules.concat(
            utils.readDir(additionalDirectory).filter(isNotBinary)
        );
    });

correctly grab the module names but then what ends up in the bundle is a require('module') without the relative path, so node won't be able to find the module without setting the NODE_PATH env variable to point to the additional node_modules locations. Is that the desired behavior?

hulkyhawk commented 3 years ago

@therealgilles is the 'module' originally an absolute request? since then it is what is desired, webpack leaves the 'module' to be handled by nodejs

therealgilles commented 3 years ago

@hulkyhawk, not sure exactly what you mean by an absolute request? do you mean an import with an absolute path? If so, no.