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