Question: is there a way to tell webpack to tell built-in modules modules like fs to execute during build so the browser gets the result of this function, not the function call itself?
My Situation:
Currently I'm developing an application for the browser using webpack. I'm trying to use the node 'fs' module in one my files to require the index.js
files from other directories. For example:
plugins
├──plugin1
│ ├── index.js (simply exports an object)
│
├──plugin2
│ ├── index.js (simply exports an object)
|
├──plugin3
│ ├── index.js (simply exports an object)
|
|──index.js (want to require all index.js from each plugin directory here)
I'm getting an error with webpack saying: Can't resolve 'fs' in somepath/node_modules/require-dir
My file index.js
located at `plugins/index.js' which is simply trying to require my other files.
//module from NPM which uses the 'fs' module ('im not explicity using it)
const requireDir = require('require-dir');
const allPlugins = requireDir('./plugins/');
console.log(allPlugins);
Can't resolve 'fs' in '/some_path/node_modules/require-dir'