esast-util-from-estree is a utility within the unified collective's ecosystem, specifically designed to convert an ESTree-compliant Abstract Syntax Tree (AST) into an esast, which is a unist-compliant AST for ECMAScript. Currently stable at version 2.0.0, this package plays a crucial role in enabling unist utilities to process JavaScript ASTs. It ensures that the transformed nodes are plain JSON objects, incorporates unist positional information, normalizes specific fields like `.bigint`, and prunes discouraged or redundant fields such as `attributes` and `selfClosing` from JSXOpeningFragment nodes to ensure strict unist compatibility. The package maintains the common release cadence of the unified collective, with major versions like v2.0.0 introducing breaking changes such as the shift to ESM-only distribution and requiring Node.js 16 or newer. Its primary differentiator is providing a robust, standard-compliant bridge between the ESTree format, typically generated by parsers like Acorn, and the unist specification.
npm install esast-util-from-estreeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing a JavaScript code string with Acorn to create an ESTree, then transforming that ESTree into an esast using `esast-util-from-estree`.
Upgrade your Node.js environment to version 16 or newer, or stick to an older major version of the package if you must support older Node.js versions.
Migrate your project to use ES modules (`import` statements) or use dynamic `import()` for this package. Ensure your `package.json` has `"type": "module"` if you're using ESM in Node.js.
Change your code from `fromEstree(estree)` to `const esast = fromEstree(estree)` to correctly capture the transformed AST.
Only import directly from the package root: `import { fromEstree } from 'esast-util-from-estree'`.Convert your file to an ES module using `import { fromEstree } from 'esast-util-from-estree'` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).Ensure you are using the return value: `const esast = fromEstree(estree)`. Do not expect `estree` to be transformed in place.
Use a named import as there is no default export: `import { fromEstree } from 'esast-util-from-estree'`.No dependency data recorded yet.