babel-plugin-react-autorequire
This plugin will autorequire all jsx components from global scope
Example
In
class Component {
render() {
return <NewComponent />;
}
}
Out
import NewComponent from "NewComponent";
class Component {
render() {
return <NewComponent />;
}
}
Installation
$ npm install babel-plugin-react-autorequire
Options
es5 : true
- will use require
instead of import
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["react-autorequire"]
}
Via CLI
$ babel --plugins react-autorequire script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["react-autorequire"]
});