Use dynamic
require()
without webpack finding out
Because webpack is super annoying. 💩
You need to supply it an absolute path.
npm install require-fool-webpack
const foo = require(getPath());
Warning from webpack:
WARNING in ./app/node_modules/conf/index.js
1:33-43 Critical dependency: the request of a dependency is an expression
@ ./app/node_modules/conf/index.js
@ ./app/node_modules/electron-store/index.js
@ ./app/config.js
@ ./app/renderer/index.js
const requireFoolWebpack = require('require-fool-webpack');
const foo = requireFoolWebpack(getPath());
No warning! \o/
MIT © Sindre Sorhus