New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

jsx-transpiler

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-transpiler

Parses and compiles JSX code to JavaScript AST or code.

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

jsx-transpiler

This is fork of jsx-recast that uses native and fast AST tools:

  • acorn-jsx for parsing JSX code to JSX AST.
  • estraverse for traversal over AST.
    • estraverse-fb for enabling traversal over JSX nodes and transforming them to JS nodes.
  • escodegen for generating JS code and source map from AST.

Purpose

Parses and compiles JSX code to JavaScript AST or code.

For example, this:

<X prop={false}><Y /></X>

compiles to this:

X({prop: false}, Y(null));

Benefits

  • Attaches comments to AST in esprima/escodegen/etc.-compatible way (extra leadingComments + trailingComments properties) when attachComment option is set (feature of esprima@1.2).
  • When comments are enabled, uses them for parsing and applying /** @jsx CustomDOM */ annotation.
  • Stores original locations in transformed nodes so source maps work for JSX elements, attributes etc.

Installation

$ npm install jsx-transpiler

Usage

As JSX -> JS AST transformer

jsx.parse('...jsx code...', {
	// ... any Acorn options ...,
	attachComment: true // additional option for comments
});
$ node
> var jsxAst = jsx.parse('<a href="#">Back to top</a>')
(JSX AST)
> jsx.transform(jsxAst)
(JS AST)

As JSX -> JS code with source map transformer

$ node
> var jsx = require('jsx-transpiler')
> jsx.compile(jsxCode)
{ "code": ..., "map": ... }

As browserify plugin

$ browserify -t jsx-transpiler $file

Keywords

react

FAQs

Package last updated on 17 Sep 2014

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