Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babylon-jsx

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babylon-jsx

Transform JSX in a babylon AST to call expressions

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Transform JSX in a babylon AST to call expressions

babylon-jsx stability

npm version Travis branch AppVeyor branch

Based on babel's transform-react-jsx.

  • Transform JSX spread to ES2015 spread
  • No babel needed
  • Cut some cruft

Installation

Grab it from npm

npm install babylon-jsx

Usage

const babylon = require('babylon');
const babylonJsx = require('babylon-jsx');
const generate = require('babel-generator');

const source = `
  <div x="x" {...y} z>
    children
  </div>
`;

const ast = parse(source, {plugins: ['jsx']});
const transformed = babylonJsx(ast, 'React.createElement');
generate(transformed);
// => React.createElement(Component, {...{ y: 2 }, ...x, ...{ z: true }});

API

transformJSX

Convert JSX in a babel ast to CallExpressions

Parameters

  • ast {Object} - babel ast to transform JSX in
  • pragma {String} - pragma to use, e.g. React.createElement

Differences to babel

babylon-jsx produces output that differs from that created by transform-react-jsx.

  • Pragmas like // @dom h are ignored
  • No extend helper is injected
  • JSX spread is transformed to ES2015 object spread
  • All produced call expressions are printed on a single line

Built by (c) Mario Nebl. Released under the MIT license.

Keywords

FAQs

Package last updated on 27 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc