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
Fragment
from samemoduleName
, default tofalse
.
$ babel --plugins transform-jsx-fragment script.js
require("babel-core").transform("code", {
plugins: ["transform-jsx-fragment"]
});