mdast-util-definitions is a small, focused utility within the unified ecosystem designed to efficiently locate definition nodes within an mdast (Markdown Abstract Syntax Tree) based on their `identifier`. Currently at stable version 6.0.0, the package primarily sees updates related to Node.js version compatibility, ESM adoption, and type improvements, consistent with the unified collective's release cadence. A key differentiator is its ability to find definitions regardless of their position in the tree (even after references), its robustness against prototype pollution, and its adherence to CommonMark precedence rules (favoring earlier definitions in case of duplicates). Since version 5.0.0, it is an ESM-only package, requiring Node.js 16+ from version 6.0.0. It provides TypeScript types for enhanced developer experience.
npm install mdast-util-definitionsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `mdast-util-definitions` to find definition nodes by identifier in an mdast tree generated from Markdown input.
Upgrade your Node.js environment to version 16 or later.
Migrate your codebase to use ES Modules (ESM) with `import` statements. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
Update your code to check for `undefined` instead of `null` when expecting a potentially missing definition.
Always use the public API through `import { definitions } from 'mdast-util-definitions'` and avoid internal paths.Ensure your project's `@types/mdast` dependency is up-to-date and compatible with `mdast-util-definitions@6`.
Convert your project or specific file to ESM and use `import { definitions } from 'mdast-util-definitions'`.Update your code to check for `undefined` instead of `null`.
Use a named import: `import { definitions } from 'mdast-util-definitions'`.Remember to call `definitions(tree)` first, which returns another function (a getter). Then call the returned getter with your identifier: `const getDefinition = definitions(tree); getDefinition('my-id');`No dependency data recorded yet.