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-jsxVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic unified pipeline using recma-build-jsx to transform JSX into React.createElement calls, parsing and stringifying the code.
Migrate your project to ES Modules or convert `require()` calls to `import()` statements where necessary. Ensure your `package.json` has `"type": "module"`.
Upgrade your Node.js runtime to version 16 or newer. Check the unified collective's compatibility guidelines for specific version requirements.
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.
Ensure `acorn` is installed in your project: `npm install acorn`.
Change `const recmaBuildJsx = require('recma-build-jsx')` to `import recmaBuildJsx from 'recma-build-jsx'` and ensure your environment supports ES Modules.Install the 'unified' package: `npm install unified`.
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'`.