In
export default function Foo() {
return (<Fragment></Fragment>);
}Out
import { Fragment } from "rax";
export default function Foo() {
return <Fragment></Fragment>;
}$ npm install babel-plugin-transform-jsx-fragment.babelrc
{
"plugins": [
["transform-jsx-fragment", {
"moduleName": "preact",
"ignoreModuleCheck": false,
}]
]
}- moduleName: String, Optional, import module name, default to 'rax'.
- ignoreModuleCheck: Boolean, Optional, ignore checking the imported
Fragmentfrom samemoduleName, default tofalse.
$ babel --plugins transform-jsx-fragment script.jsrequire("babel-core").transform("code", {
plugins: ["transform-jsx-fragment"]
});