Transforms all calls of require
into calls of the SystemJS internal $__require
.
In
require('test/');
Out
$__require('test');
$ npm install babel-plugin-transform-cjs-system-require
.babelrc
{
"plugins": [
["transform-cjs-system-require", {}]
]
}
$ babel --plugins transform-cjs-system-require script.js
require("babel-core").transform("code", {
plugins: [
["transform-cjs-system-require", {
requireName: "require", // optional
mappedRequireName: "$__require", // optional
map: function(name) { // optional
return normalize(name);
}
}]
]
});