A Babel plugin that transforms webpack-specific require.context()
into dummy function calls so that the code can run safely outside of the webpack environment, e.g. in Node.
It doesn't perform any file lookup or dynamic require, but should not break the code otherwise.
$ npm install babel-plugin-transform-require-context
.babelrc
{
"plugins": ["transform-require-context"]
}
$ babel --plugins transform-require-context script.js
require("@babel/core").transform("code", {
plugins: ["transform-require-context"]
});