npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thinkeloquent/ast-append-ids

v1.0.0

Published

Unified AST ID appender for JSX, XML, and HTML with WASM implementation

Readme

@thinkeloquent/ast-append-ids

Unified AST ID appender for JSX, XML, and HTML with high-performance WASM implementation. This package automatically loads the appropriate WASM build based on your environment.

Features

  • 🚀 High-performance Rust/WASM implementation
  • 🎯 Automatic environment detection (Browser, Node.js, Bundlers)
  • 📦 Support for JSX, XML, and HTML processing
  • 🔧 Compatible with Babel, Rehype, and XAST ecosystems
  • 💻 Works in browsers, Node.js, and bundler environments
  • 🔄 Deterministic ID generation

Installation

npm install @thinkeloquent/ast-append-ids

or

yarn add @thinkeloquent/ast-append-ids

Usage

ESM (Modern JavaScript)

import { 
  babelPluginJsxAppendIds, 
  rehypeAppendIds, 
  xastAppendIds,
  WasmAstProcessor 
} from '@thinkeloquent/ast-append-ids';

// Process JSX
const jsxResult = await babelPluginJsxAppendIds(jsxContent, {
  idPrefix: 'jsx',
  preserveExisting: true
});

// Process HTML
const htmlResult = await rehypeAppendIds(htmlContent, {
  idPrefix: 'html',
  idAttribute: 'data-id'
});

// Process XML
const xmlResult = await xastAppendIds(xmlContent, {
  idPrefix: 'xml',
  idSeparator: '-'
});

// Using the processor class
const processor = new WasmAstProcessor();
const result = await processor.processAuto(content, options);
processor.free(); // Clean up when done

CommonJS

const { 
  babelPluginJsxAppendIds,
  rehypeAppendIds,
  xastAppendIds,
  WasmAstProcessor 
} = require('@thinkeloquent/ast-append-ids');

// All functions return promises in CommonJS
async function processContent() {
  const result = await babelPluginJsxAppendIds(content, options);
  console.log(result);
}

Browser

The package automatically loads the web-optimized WASM build when used in browsers:

<script type="module">
import { babelPluginJsxAppendIds } from '@thinkeloquent/ast-append-ids';

const result = await babelPluginJsxAppendIds(jsxContent, {
  idPrefix: 'component'
});
</script>

API

Functions

create_default_options()

Returns the default options object for processing.

version()

Returns the version of the WASM module.

babelPluginJsxAppendIds(content, options)

Process JSX content and append IDs to elements.

rehypeAppendIds(content, options)

Process HTML content using rehype and append IDs.

xastAppendIds(content, options)

Process XML content using xast and append IDs.

WasmAstProcessor Class

A class providing methods for processing different content types:

  • processJsx(content, options) - Process JSX content
  • processXml(content, options) - Process XML content
  • processHtml(content, options) - Process HTML content
  • processAuto(content, options) - Auto-detect content type and process
  • free() - Clean up WASM resources

Options

All processing functions accept an options object:

interface ProcessorOptions {
  idAttribute?: string;      // Attribute name for IDs (default: 'id')
  idPrefix?: string;         // Prefix for generated IDs
  idSeparator?: string;      // Separator for ID parts (default: '_')
  skipIds?: boolean;         // Skip ID generation
  preserveExisting?: boolean; // Preserve existing IDs
}

Environment Detection

The package automatically detects and loads the appropriate WASM build:

  • Browser: Loads the web-optimized build from pkg-web
  • Node.js: Loads the Node.js-specific build from pkg-node
  • Bundlers (Webpack, Rollup, Vite): Loads the bundler-optimized build from pkg-bundler

CLI Usage

The package includes a CLI tool:

npx ast-append-ids process input.jsx --output output.jsx --type jsx

Performance

This package uses a high-performance Rust/WASM implementation that provides:

  • Fast parsing and transformation
  • Low memory footprint
  • Deterministic ID generation
  • Efficient handling of large files

License

MIT

Author

ThinkEloquent

Repository

https://github.com/thinkeloquent/ast-append-ids