Registry / babel-helper-builder-react-jsx

babel-helper-builder-react-jsx

JSON →
library6.26.0jsnpmunverified

Internal Babel helper for building React JSX AST nodes, used by @babel/plugin-transform-react-jsx and related plugins. This package provides a builder function that creates call expressions (e.g., React.createElement) from JSX AST elements. Version 6.26.0 is the latest stable release, part of Babel 6.x, which is now in maintenance mode. Key differentiator: it is strictly a Babel internals helper, not intended for direct consumer use. Alternatives: use @babel/plugin-transform-react-jsx directly for JSX transformation.

npm install babel-helper-builder-react-jsx
INSTALL
IMPORT
SIG · BABEL-HELPER-BUILD
B
babel-helper-builder-react-jsx
javascriptv6.26.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
import buildReactJSX from 'babel-helper-builder-react-jsx'
const { default } = require('babel-helper-builder-react-jsx')
Default export only; named exports not available.

Demonstrates how to use the builder to replace JSXElement nodes with call expressions, including pre/post hooks.

import buildReactJSX from 'babel-helper-builder-react-jsx'; import * as t from 'babel-types'; const builder = buildReactJSX({ pre(state) { state.tagName = state.tagName === 'div' ? 'span' : state.tagName; }, post(state) { // Tag is already transformed into a call expression in state.call } }); // Build a JSX element in a visitor const visitor = { JSXElement(path) { const state = { tagExpr: path.node.openingElement.name, tagName: path.node.openingElement.name.name, args: [path.node.children.flatMap(child => { if (t.isJSXText(child)) { return t.stringLiteral(child.value); } return child; // transformed elsewhere })] }; const result = builder(state); path.replaceWith(result); } };
Debug
Known issues
gotchaThis package exposes a single default function that returns an AST builder. It does NOT handle JSX transformation itself; you must use it inside a Babel plugin.
fix
Use @babel/plugin-transform-react-jsx directly for JSX transformation.
affects: >=6.0.0
deprecatedThis package is deprecated in favor of @babel/helper-builder-react-jsx (Babel 7+) or the new JSX transform (React 17+).
fix
Use @babel/plugin-transform-react-jsx or @babel/plugin-transform-react-jsx-development in Babel 7+.
affects: <=6.26.0
gotchaThe builder expects state.args to be an array of arguments for the call expression (e.g., props, children). Incorrectly formed args can produce invalid AST.
fix
Ensure args is an array of AST nodes (not strings or objects).
affects: >=6.0.0
Errors
Common errors & fixes
Cannot find module 'babel-helper-builder-react-jsx'
Package not installed or trying to use with Babel 7+ where it was renamed.
fix
Install the correct version: npm install babel-helper-builder-react-jsx@6 --save-dev, or switch to @babel/helper-builder-react-jsx for Babel 7+.
TypeError: builder is not a function
Importing the default export incorrectly (e.g., using { buildReactJSX } import syntax).
fix
Use default import: import buildReactJSX from 'babel-helper-builder-react-jsx'
ReferenceError: require is not defined
Trying to use CommonJS require in an ESM context.
fix
Use ESM import: import buildReactJSX from 'babel-helper-builder-react-jsx'
Upgrade
Version history
6.26.0latest on npm
Audit
Dependencies
babel-typesrequiredUsed for AST node construction and type checking.
lodashrequiredUsed for utility functions like cloneDeep.
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
babel-helper-builder-react-jsx — npm install babel-helper-builder-react-jsx · libregistry