Last updated: December 2025 | For AI assistants working with hpcc-systems/hpcc-js-wasm
This document provides guidance for AI assistants working with the HPCC-JS-WASM repository.
This is a monorepo that provides WebAssembly (WASM) versions of popular C++ libraries for use in Node.js, web browsers, and JavaScript applications. It uses Lerna for monorepo management and npm workspaces.
- @hpcc-js/wasm-base91 - Base91 encoding/decoding library
- @hpcc-js/wasm-duckdb - DuckDB embedded database
- @hpcc-js/wasm-expat - Expat XML parser
- @hpcc-js/wasm-graphviz - Graphviz graph visualization library
- @hpcc-js/wasm-graphviz-cli - Command-line interface for Graphviz
- @hpcc-js/wasm-llama - Llama.cpp AI model library
- @hpcc-js/wasm-zstd - Zstandard compression library
- @hpcc-js/wasm - Meta package for backward compatibility
├── packages/ # Individual WASM packages
│ ├── base91/ # Base91 package
│ ├── duckdb/ # DuckDB package
│ ├── expat/ # Expat package
│ ├── graphviz/ # Graphviz package
│ ├── graphviz-cli/ # Graphviz CLI package
│ ├── llama/ # Llama package
│ ├── wasm/ # Meta package
│ └── zstd/ # Zstd package
├── src-cpp/ # Shared C++ source code
├── scripts/ # Build and utility scripts
├── docs/ # Documentation (VitePress)
└── .vscode/ # VSCode configuration
Each package typically contains:
packages/[name]/
├── src/ # TypeScript source
├── src-cpp/ # C++ source code
├── tests/ # Test files
├── package.json # Package configuration
└── vitest.config.ts # Test configuration
# Install dependencies
npm ci
# Install build dependencies (requires system tools)
npm run install-build-deps # Installs emsdk, vcpkg, playwright, bundler test deps
# Build C++ to WASM (requires emscripten)
npm run build-cpp
# Build TypeScript packages
npm run build-wsNotes:
- CI runs Node.js 22 and 24; docs deploy currently uses Node.js 20.
- Browser tests typically require
npx playwright install --with-depson Ubuntu.
# Install dependencies
npm ci
# Build only TypeScript (without C++ compilation)
npm run build-ws
# Run linting
npm run lint
# Note: Tests may fail without WASM builds# Run all tests (requires full build)
npm run test
# Run specific package tests
cd packages/graphviz && npm test
# Run browser tests
npm run test-browser
# Run node tests
npm run test-nodeAll WASM libraries follow this pattern:
import { LibraryName } from "@hpcc-js/wasm-libraryname";
// Async loading required
const library = await LibraryName.load();
// Use library methods
const result = library.someMethod(input);// src/index.ts - Main entry point
export * from "./libraryname.ts";
// src/libraryname.ts - Main implementation
export class LibraryName {
static async load(): Promise<LibraryName> { ... }
someMethod(input: string): string { ... }
version(): string { ... }
}import { describe, it, expect } from "vitest";
import { LibraryName } from "@hpcc-js/wasm-libraryname";
describe("LibraryName", () => {
it("basic functionality", async () => {
const lib = await LibraryName.load();
const result = lib.someMethod("test");
expect(result).toBeDefined();
});
});- TypeScript - Primary language for package implementations
- C++ - Source libraries compiled to WASM
- Emscripten - C++ to WASM compilation toolchain
- Lerna - Monorepo management
- Vitest - Testing framework (with browser support)
- ESBuild - TypeScript bundling
- VitePress - Documentation generation
- vcpkg - C++ package manager for dependencies
- emscripten - Compiles C++ to WASM
- IDL files - WebIDL bindings for C++ classes
- Custom esbuild plugins - Handle WASM imports
- tsc - Type generation
- esbuild - Bundling (ESM, CJS, UMD formats)
- Custom plugins - WASM asset handling
- Missing WASM files: Run
npm run build-cppfirst - Type errors: Ensure all packages are built with
npm run build-ws - Test failures in fresh clone: Expected - requires full build process
- Packages depend on each other being built
- Use relative imports for local development
- Run
lerna run buildto build all packages
- WASM files must be accessible at runtime
- Browser requires proper MIME types for .wasm files
- Node.js needs appropriate file system access
- Launch configurations provided for browser and Node.js debugging
- Tasks configured for watch mode development
- CMake integration for C++ development
Most libraries support debug output:
// Enable debug logging
const lib = await LibraryName.load({ debug: true });- API Docs: Generated with TypeDoc at https://hpcc-systems.github.io/hpcc-js-wasm/
- Examples: See
/examplesdirectory and live demos in root:hw-graphviz.html- Graphviz graph renderinghw-zstd.html- Compression exampleshw-base91.html- Encoding demosindex.html- Package showcase
- Package READMEs: Each package has specific documentation
- Understand the monorepo structure - changes may affect multiple packages
- Follow existing patterns - each package follows similar structure
- Test incrementally - build and test after each significant change
- Consider WASM implications - changes to C++ require full rebuild
- Update documentation - maintain TypeDoc comments and READMEs
- TypeScript code changes in
src/directories - Test file modifications
- Documentation updates
- Package.json script modifications
- C++ source code changes in
src-cpp/directories - WebIDL (.idl) file changes
- CMakeLists.txt modifications
- New WASM library additions
- Run
npm run lintto check code style - Run
npm run build-wsto ensure TypeScript builds - If C++ was modified, run full build cycle
- Test affected packages individually
- Update relevant documentation