Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

sindresorhus/require-fool-webpack

Repository files navigation

require-fool-webpack

Use dynamic require() without webpack finding out

Because webpack is super annoying. 💩

You need to supply it an absolute path.

Install

npm install require-fool-webpack

Usage

Before

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

After

const requireFoolWebpack = require('require-fool-webpack');
const foo = requireFoolWebpack(getPath());

No warning! \o/

License

MIT © Sindre Sorhus