Registry / web-framework / babel-plugin-jsx

babel-plugin-jsx

JSON →
library1.2.0jsnpmunverified

A Babel plugin that transforms JSX into a generic intermediate representation (JSX-IR) rather than React.createElement calls. Version 1.2.0 is the current stable release with no active development since 2017. The plugin outputs plain objects with tag, props, and children fields, making it renderer-agnostic. Key differentiators: it does not require React, supports scope capture for variable resolution, and can be combined with custom renderers from the jsx-ir ecosystem.

npm install babel-plugin-jsx
INSTALL
IMPORT
SIG · BABEL-PLUGIN-JSX
B
babel-plugin-jsx
web-frameworkjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default plugin
babel.transform(code, { plugins: ['babel-plugin-jsx'] })
var plugin = require('babel-plugin-jsx'); babel.transform(code, { plugins: [plugin] })
The plugin is a function that must be used as a string reference in babel configuration, not required directly.
plugin generator
var jsxGen = require('babel-plugin-jsx/gen'); var plugin = jsxGen({ captureScope: true })
var plugin = require('babel-plugin-jsx').gen({ captureScope: true })
The generator is required from 'babel-plugin-jsx/gen', not a property of the main module.
babel-plugin-jsx/gen
import jsxGen from 'babel-plugin-jsx/gen'
import { gen } from 'babel-plugin-jsx'
Named import from main module does not work; use default import from subpath.

Transforms JSX code into JSX-IR object using the plugin generator with captureScope disabled.

const babel = require('babel-core'); const jsxGen = require('babel-plugin-jsx/gen'); const code = '<div className="box"><List><ListItem index={1} /></List></div>'; const result = babel.transform(code, { plugins: [jsxGen({ captureScope: false })], blacklist: ['react'] }); console.log(result.code); // Output: JSX-IR object
Debug
Known issues
gotchaBabel 6+ blacklist option is deprecated; use 'only' or 'exclude' instead.
fix
Use 'exclude' option or upgrade to Babel 7+ and use 'overrides'
affects: >=1.0.0
deprecatedThe 'blacklist' option is no longer supported in Babel 7. Plugin may not work with Babel 7.
fix
Upgrade to a Babel 7 compatible plugin or use Babel 6.
affects: >=1.0.0
gotchaScope capture requires variables to be in scope or defined as builtins; missing variables cause compilation error by default.
fix
Set throwOnMissing: false to defer to runtime error or ensure all JSX tags are in scope.
affects: >=1.0.0
gotchaPlugin is designed for Babel 6; using with Babel 7 may cause unexpected errors due to API changes.
fix
Use Babel 6 or find a Babel 7 compatible alternative.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: [BABEL] unknown: Plugin . was not found
Trying to require the plugin directly and pass as object instead of using string reference.
fix
Use 'plugins: ["babel-plugin-jsx"]' or require the generator submodule: 'plugins: [require("babel-plugin-jsx/gen")()]'
Error: Couldn't find scope for tag: SomeComponent
Using captureScope: true without having the variable SomeComponent defined in scope or listed in builtins.
fix
Define the variable in scope, add it to builtins array, or set throwOnMissing: false
TypeError: Cannot read property 'name' of undefined
Using babel-plugin-jsx with Babel 7 where the plugin API changed.
fix
Use Babel 6 or replace the plugin with a Babel 7 compatible JSX-IR plugin.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
babel-plugin-jsx — npm install babel-plugin-jsx · libregistry