Skip to content

Packages Overview

The AST toolkit is organized as a monorepo with multiple packages. This modular architecture allows you to install only what you need.

Package Structure

@sylphlab/ast-*
├── @sylphlab/ast-core         # Core AST types (required)
└── @sylphlab/ast-javascript   # JavaScript parser

Core Package

@sylphlab/ast-core

The foundation for all language parsers

bash
pnpm add @sylphlab/ast-core

This package provides:

  • Generic AST node interfaces
  • Base types for all parsers
  • Position and location tracking
  • Zero external dependencies
  • Full TypeScript type definitions

Key Types:

  • AstNode - Base interface for all AST nodes
  • Program - Root node of an AST
  • Statement - Base for all statements
  • Expression - Base for all expressions
  • SourceLocation - Position tracking

View documentation →

Language Parsers

@sylphlab/ast-javascript

JavaScript/ECMAScript parser powered by ANTLR

bash
pnpm add @sylphlab/ast-javascript

Features:

  • Full ECMAScript support
  • ANTLR-based parsing
  • Custom visitor for AST transformation
  • Source location tracking
  • Error recovery

Dependencies:

  • @sylphlab/ast-core (required)
  • antlr4ts (ANTLR runtime)

View documentation →

Installation

Install Core + JavaScript Parser

bash
pnpm add @sylphlab/ast-core @sylphlab/ast-javascript
bash
npm install @sylphlab/ast-core @sylphlab/ast-javascript
bash
yarn add @sylphlab/ast-core @sylphlab/ast-javascript

Install Core Only

If you're building your own parser:

bash
pnpm add @sylphlab/ast-core
bash
npm install @sylphlab/ast-core
bash
yarn add @sylphlab/ast-core

Package Comparison

Feature@sylphlab/ast-core@sylphlab/ast-javascript
PurposeCore typesJavaScript parser
DependenciesNoneast-core, antlr4ts
Size~10KB~500KB (includes grammar)
When to useBuilding custom parsersParsing JavaScript
ExportsTypes onlyParser + types

Version Compatibility

All packages follow semantic versioning:

  • Major version - Breaking API changes
  • Minor version - New features (backward compatible)
  • Patch version - Bug fixes

Current Versions

PackageVersionStatus
@sylphlab/ast-core0.0.0Alpha
@sylphlab/ast-javascript0.0.0Alpha

WARNING

These packages are currently in alpha. APIs may change before 1.0.0 release.

Package Details

Dependencies

@sylphlab/ast-javascript
├── @sylphlab/ast-core@workspace:*
└── antlr4ts@0.5.0-alpha.4

@sylphlab/ast-core
└── (no dependencies)

Bundle Sizes

PackageMinifiedMinified + Gzipped
@sylphlab/ast-core~10 KB~3 KB
@sylphlab/ast-javascript~500 KB~120 KB

TIP

The JavaScript parser includes ANTLR runtime and generated grammar, which accounts for most of the bundle size.

Module Formats

All packages support multiple module formats:

ESM (ECMAScript Modules)

typescript
import { parse } from '@sylphlab/ast-javascript';
import type { AstNode } from '@sylphlab/ast-core';

CommonJS

javascript
const { parse } = require('@sylphlab/ast-javascript');

TypeScript

Full TypeScript support with .d.ts type declarations:

typescript
import type { Program, Statement, Expression } from '@sylphlab/ast-core';

Tree Shaking

All packages are tree-shakeable when using ESM:

typescript
// Only imports what you use
import { parse } from '@sylphlab/ast-javascript';

// Bundle will only include parse function and dependencies

Peer Dependencies

Some packages may have peer dependencies:

json
{
  "peerDependencies": {
    "typescript": ">=5.0.0"
  },
  "peerDependenciesMeta": {
    "typescript": {
      "optional": true
    }
  }
}

Package Registry

All packages are published to npm:

  • Registry: npmjs.com
  • Scope: @sylphlab
  • Access: Public

Future Packages

Planned language parsers:

  • @sylphlab/ast-typescript - TypeScript parser
  • @sylphlab/ast-python - Python parser
  • @sylphlab/ast-go - Go parser
  • @sylphlab/ast-rust - Rust parser

Utility packages:

  • @sylphlab/ast-utils - AST manipulation utilities
  • @sylphlab/ast-traverse - AST traversal helpers
  • @sylphlab/ast-codegen - Code generation from AST

Package Development

Interested in contributing a new language parser?

  1. Read the Adding Languages Guide
  2. Check out the Development Guide
  3. Open a discussion on GitHub

Support Matrix

Node.js Versions

Node.js VersionSupported
20.x✅ Yes
18.x✅ Yes
16.x⚠️ Best effort
14.x❌ No

TypeScript Versions

TypeScript VersionSupported
5.8.x✅ Yes (recommended)
5.0.x - 5.7.x✅ Yes
4.x⚠️ May work
3.x❌ No

Explore the documentation for each package:

Next Steps


Questions? Open an issue or contact us.

Released under the MIT License.