unist-builder is a utility package providing a hyperscript-like interface for programmatically constructing unist (Universal Syntax Tree) nodes and trees. It simplifies the creation of Abstract Syntax Trees (ASTs) by replacing repetitive manual object creation with a concise functional API, similar to `createElement` in React or `h` in Vue. The current stable version is 4.0.0, which targets Node.js 16 and later. The package generally follows a deliberate release cadence, with major versions often introducing breaking changes related to Node.js compatibility or module system shifts (e.g., transitioning to ESM). It differentiates itself by offering a fluent API specifically for unist, contrasting with related tools like `hastscript` or `xastscript` which serve HTML and XML ASTs respectively.
npm install unist-builderVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a nested unist tree structure using the `u` function with various node types, properties, children, and values.
Upgrade your Node.js environment to version 16 or higher.
Migrate your project to use ES modules (`import`) for `unist-builder`. For Node.js, ensure your `package.json` includes `"type": "module"` or use dynamic `import()` within CommonJS files.
Update `@types/unist` to a compatible version (e.g., `npm install @types/unist@latest`) and resolve any type conflicts in your TypeScript project to align with `unist-builder`'s expectations.
Always import symbols directly from `unist-builder` (e.g., `import { u } from 'unist-builder'`). Avoid attempting to import from internal paths like `unist-builder/lib/some-internal-file`.Ensure your JavaScript execution environment supports `Object.assign`. If targeting extremely old browsers, consider a polyfill (though generally not necessary for Node.js usage).
Ensure your `package.json` contains `"type": "module"` or use dynamic `import('unist-builder').then(...)` if you must remain in a CommonJS context.Use the correct ESM named import: `import { u } from 'unist-builder'`. If in a CommonJS file and Node.js v14+, use `const { u } = await import('unist-builder')`.Switch to `import` statements (e.g., `import { u } from 'unist-builder'`) as the package is ESM-only since v3.0.0.Import only from the main `unist-builder` package directly: `import { u } from 'unist-builder'`. Avoid internal or private paths as they are not guaranteed API.No dependency data recorded yet.