babel-plugin-transform-require-default
v0.1.7
Published
Auto transform require to require default in Babel 6/7
Downloads
5,427
Readme
babel-plugin-transform-require-default
Why
Babel@6/7 doesn't export default module.exports any more - T2212 Kill CommonJS default export behavior
It means in a ES6 module, you have to use require
like:
const A = require('a').default;
How it works
transform:
const A = require('a');
into
function __require_default_func__(module) { return module && module.__esModule ? module["default"] : module; }
const A = __require_default_func__(require('a'));
Options
exclude
string/regexp/function/array
, exclude module
{
plugins: [
['transform-require-default', {
exclude: "lodash",
exclude: /lodash/,
exclude: [
/lodash/,
"react"
],
exclude(module) {
return module === 'lodash';
}
}]
]
}