跳到主要内容

@babel/plugin-syntax-jsx

备注

Syntax only

Using this plugin directly only enables Babel to parse this syntax. If you want to transform JSX syntax then use the transform-react-jsx plugin or react preset to both parse and transform this syntax.

Installation

npm install --save-dev @babel/plugin-syntax-jsx

Usage

babel.config.json
{
"plugins": ["@babel/plugin-syntax-jsx"]
}

Via CLI

Shell
babel --plugins @babel/plugin-syntax-jsx script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-jsx"],
});