Registry / serialization / recma-build-jsx

recma-build-jsx

JSON →
library1.0.0jsnpmunverified

This package, `recma-build-jsx`, is a plugin within the unified ecosystem, specifically designed for `recma` (a sub-project focused on JavaScript Abstract Syntax Trees). Its primary function is to transform JSX syntax (e.g., `<x />`) found in a JavaScript AST into standard JavaScript function calls, such as `React.createElement('x', {})` or `_jsx('x', {})`, making the JSX evaluable in a runtime environment. Currently at version 1.0.0, the `recma` collective maintains compatibility with actively supported Node.js versions, with new major releases typically dropping support for unmaintained Node.js runtimes. This plugin is essential when processing JavaScript code containing JSX as part of a larger transformation pipeline, often alongside other `recma` plugins like `recma-parse` (for parsing), `recma-jsx` (for enabling JSX parsing), and `recma-stringify` (for serializing back to code). It differentiates itself by integrating seamlessly into the `unified` processing flow, abstracting lower-level utilities like `estree-util-build-jsx` for a higher-level declarative API.

npm install recma-build-jsx
INSTALL
IMPORT
SIG · RECMA-BUILD-JSX
R
recma-build-jsx
serializationjavascriptv1.0.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.

recmaBuildJsx
import recmaBuildJsx from 'recma-build-jsx'
const recmaBuildJsx = require('recma-build-jsx')
recma-build-jsx is an ESM-only package since v1.0.0.
unified
import { unified } from 'unified'
import unified from 'unified'
The `unified` function is a named export from the 'unified' package.
recmaJsx
import recmaJsx from 'recma-jsx'
const recmaJsx = require('recma-jsx')
Similar to recma-build-jsx, 'recma-jsx' is an ESM-only package.

Demonstrates a basic unified pipeline using recma-build-jsx to transform JSX into React.createElement calls, parsing and stringifying the code.

import recmaBuildJsx from 'recma-build-jsx'; import recmaJsx from 'recma-jsx'; import recmaParse from 'recma-parse'; import recmaStringify from 'recma-stringify'; import { unified } from 'unified'; async function transformJsx() { const file = await unified() .use(recmaParse) .use(recmaJsx) // Enables JSX parsing .use(recmaBuildJsx) // Transforms JSX into JS calls .use(recmaStringify) // Converts AST back to string .process('console.log(<em>Hello, world!</em>)'); console.log(String(file)); } transformJsx(); // Expected output in Node.js 16+ (top-level await): // console.log(React.createElement("em", null, "Hello, world!"));
Debug
Known issues
breakingThis package is ESM-only. Attempting to `require()` it will result in a runtime error. Ensure your project is configured for ESM or use dynamic `import()`.
fix
Migrate your project to ES Modules or convert `require()` calls to `import()` statements where necessary. Ensure your `package.json` has `"type": "module"`.
affects: >=1.0.0
breakingrecma-build-jsx and the unified collective packages are compatible only with maintained versions of Node.js. Version 1.0.0 requires Node.js 16 or higher.
fix
Upgrade your Node.js runtime to version 16 or newer. Check the unified collective's compatibility guidelines for specific version requirements.
affects: >=1.0.0
gotchaAs recma processes and potentially evaluates JavaScript code, it can be unsafe if applied to untrusted or malicious input. Always sanitize or validate input when handling external content.
fix
Never evaluate transformed JavaScript from untrusted sources directly. Implement strict content security policies and input validation for any user-generated or external content processed by recma.
affects: >=1.0.0
gotchaWhen using `recma-jsx` (a common companion plugin) with `recma-build-jsx`, a peer dependency on `acorn` is required. Missing `acorn` can lead to parsing errors.
fix
Ensure `acorn` is installed in your project: `npm install acorn`.
affects: >=1.0.1 (for recma-jsx)
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... recma-build-jsx/index.js not supported.
Attempting to use `require()` to import an ESM-only package.
fix
Change `const recmaBuildJsx = require('recma-build-jsx')` to `import recmaBuildJsx from 'recma-build-jsx'` and ensure your environment supports ES Modules.
Error: Cannot find module 'unified'
The 'unified' package, a core dependency, is not installed.
fix
Install the 'unified' package: `npm install unified`.
TypeError: (0, _recmaBuildJsx.default) is not a function
Incorrectly trying to destructure the default export or importing a named export that doesn't exist as default.
fix
Ensure you are using `import recmaBuildJsx from 'recma-build-jsx'` for the default export. If a named export is expected, use `import { namedExport } from 'recma-build-jsx'`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
unifiedrequiredCore processor for the unified ecosystem, required to use recma-build-jsx as a plugin.
recma-parserequiredCommonly used alongside recma-build-jsx to parse JavaScript code into an AST.
recma-jsxrequiredRequired to enable parsing of JSX syntax within the recma pipeline.
recma-stringifyrequiredOften used to serialize the transformed AST back into JavaScript code.
acornrequiredPeer dependency of `recma-jsx` (a common companion plugin), necessary for JavaScript parsing.
Agent activity
6 hits · last 30 days
node
6
Resources
recma-build-jsx — npm install recma-build-jsx · libregistry