xastscript is a utility library providing a hyperscript-like interface for programmatically creating xast (XML Abstract Syntax Tree) nodes. Similar to React's `createElement` or `hastscript` for HTML, it simplifies the creation of XML syntax trees by allowing nested function calls instead of verbose object literals. The current stable version is 4.0.0, which requires Node.js 16 or later and is exclusively ESM. It's part of the unified ecosystem and is primarily used when generating XML structures within code. Unlike `unist-builder` which handles generic unist nodes, `xastscript` is specifically tailored for XML elements, providing convenience for defining attributes and children in a more declarative way. Its release cadence typically involves minor and patch updates every few months, with major versions occurring less frequently, driven by breaking changes or significant feature additions.
npm install xastscriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating xast XML elements with attributes and children using both array and argument-based child passing, and integrating with `unist-builder` for non-element xast nodes like comments and processing instructions.
Upgrade your Node.js environment to version 16 or later. If unable to upgrade, consider using `xastscript` v3.x which supports Node.js 12+.
Refactor your imports to use ES Modules syntax (`import { x } from 'xastscript';`). Ensure your project is configured for ESM by setting `"type": "module"` in your `package.json` or by using `.mjs` file extensions. In CommonJS files, dynamic `import()` can be used.Remove `@types/xastscript` from your `devDependencies`. Ensure your `tsconfig.json` correctly resolves types from `xastscript` itself. Review and update any explicit dependencies on `@types/xast`.
To use JSX with `xastscript`, configure your `tsconfig.json` (for TypeScript) or Babel presets. For example, in `tsconfig.json`: `"compilerOptions": { "jsx": "react-jsx", "jsxFactory": "x", "jsxFragmentFactory": null }`.Change `const { x } = require('xastscript');` to `import { x } from 'xastscript';`. Ensure your `package.json` includes `"type": "module"` if this is a Node.js project or use `.mjs` file extensions.Verify your build setup handles ES Modules correctly. Always use named imports for `x` (e.g., `import { x } from 'xastscript';`). If using TypeScript, check `tsconfig.json` for `moduleResolution` and `module` settings.Double-check your `import { x } from 'xastscript';` statement for typos. Ensure `xastscript` is correctly installed in `node_modules`. If running in a browser, ensure `esm.sh` or similar CDN imports are correct and bundled if necessary.No dependency data recorded yet.