estree-util-build-jsx is a utility designed to transform JSX nodes within an ESTree (Abstract Syntax Tree) into standard function calls, such as those used by `h` (hyperscript) functions for React, Preact, or custom renderers. This package currently stands at version 3.0.1, with recent major updates in 3.0.0 introducing breaking changes like ESM-only distribution and requiring Node.js 16+. Its release cadence is active, with consistent updates and bug fixes. A key differentiator is its focus on AST transformation rather than full code compilation, making it suitable for pipelines where an AST is already available (e.g., from Acorn or other parsers). Unlike comprehensive compilers like SWC or esbuild, it does not parse raw source code. It also has specific behavioral differences compared to Babel's JSX transform, such as explicit support for namespaces and different handling of `this` as a component.
npm install estree-util-build-jsxVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing JSX with `acorn-jsx`, transforming the resulting ESTree using `buildJsx` to convert JSX elements into function calls, and then converting the modified tree back into JavaScript code.
Upgrade your Node.js environment to version 16 or newer. For projects requiring older Node.js, use a previous major version of `estree-util-build-jsx` (e.g., `2.x`).
Update your import statements to use ES modules (`import ... from 'pkg'`). Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
After calling `buildJsx(tree, options)`, continue using the original `tree` object as it has been modified directly. Do not attempt to assign the return value of `buildJsx`.
Replace all occurrences of `BuildJsxOptions` with `Options` in your TypeScript code.
Only use the officially exported symbols as documented in the API. Avoid importing from deep paths or relying on non-public APIs.
Change `const { buildJsx } = require('estree-util-build-jsx')` to `import { buildJsx } from 'estree-util-build-jsx'`. Ensure your project's `package.json` has `"type": "module"` or your file uses the `.mjs` extension.Verify the import is `import { buildJsx } from 'estree-util-build-jsx'`. If on v3.0.0+, remember that `buildJsx` modifies the tree in place and returns `undefined`, so don't assign its result.Update the type reference from `BuildJsxOptions` to `Options`.
Ensure the containing file is treated as an ES module by either naming it `.mjs` or adding `"type": "module"` to your nearest `package.json` file.
No dependency data recorded yet.