Skip to content

jsx-plus/babel-plugin-transform-jsx-fragment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"]
});