0.1.5 • Published 1 year ago

babel-plugin-transform-jsx-fragment v0.1.5

Weekly downloads
2,000
License
-
Repository
-
Last release
1 year ago

babel-plugin-transform-jsx-fragment

Example

In

export default function Foo() {
  return (<Fragment></Fragment>);
}

Out

import { Fragment } from "rax";

export default function Foo() {
  return <Fragment></Fragment>;
}

Installation

$ npm install babel-plugin-transform-jsx-fragment

Usage

Via .babelrc (Recommended)

.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 same moduleName, default to false.

Via CLI

$ babel --plugins transform-jsx-fragment script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-jsx-fragment"]
});