hast-util-to-estree is a utility package within the unified/syntax-tree ecosystem designed to transform a HTML Abstract Syntax Tree (hast) into an ECMAScript Abstract Syntax Tree (estree) with JSX extensions. This is particularly useful for embedding HTML content as JSX within JavaScript, such as in MDX. The current stable version is 3.1.3, with releases occurring regularly, often involving minor updates to dependencies or new options, indicating active maintenance. Key differentiators include its specific focus on the hast-to-estree transformation, robust handling of JSX, support for embedded MDX nodes, and its adherence to the unist specification, making it a reliable component in pipelines involving content transformation and compilation.
npm install hast-util-to-estreeVerified import paths — ran on the pinned version, not inferred.
Demonstrates transforming a raw HTML string into an ESTree (JavaScript AST) with JSX nodes, then rendering it to a JSX-compatible string using companion utilities.
Upgrade your Node.js environment to version 16 or newer. Use `nvm` or `volta` for managing Node.js versions.
Migrate your codebase to use ES Modules `import` syntax. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
Update your `@types/hast` dependency to a compatible version (typically the latest stable release) in your `package.json`.
If experiencing issues with comment handling in down-stream compilers, explicitly remove the `comments` array from the program node: `estree.comments = undefined;`.
Utilize options like `elementAttributeNameCase` or `stylePropertyNameCase` during transformation, or apply a post-processing step if your target framework requires specific attribute naming conventions.
Change your import statement to `import { toEstree } from 'hast-util-to-estree'` and ensure your Node.js project or file is configured for ES Modules.Ensure you are using a named import: `import { toEstree } from 'hast-util-to-estree'`.Verify that you are using the correct named import: `import { toEstree } from 'hast-util-to-estree'`. Check your package version for any breaking changes related to exports.No dependency data recorded yet.