Registry / serialization / trastpiler

trastpiler

JSON →
library1.0.2jsnpmunverified

trastpiler is a lightweight, agnostic AST transpiler for JavaScript. Version 2.0.0 introduces breaking changes over 1.x, with a focus on plugin-based transformations and improved TypeScript support. It allows traversing and transforming Abstract Syntax Trees (ASTs) using a simple visitor pattern. Unlike Babel or jscodeshift, trastpiler is designed to be minimal and framework-agnostic, with no built-in parsing — you supply your own AST. Development appears intermittent; the latest release is 2.0.0, published roughly monthly during active phases. It targets Node >=8.6 and has no runtime dependencies.

npm install trastpiler
INSTALL
IMPORT
SIG · TRASTPILER
T
trastpiler
serializationjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

traverse
import { traverse } from 'trastpiler'
const traverse = require('trastpiler').traverse;
Package is ESM-only since v2; CommonJS require will fail unless using dynamic import.
transform
import { transform } from 'trastpiler'
import trastpiler from 'trastpiler'; trastpiler.transform(...)
transform is a named export, not a default export.
types
import type { ASTNode, Visitor } from 'trastpiler'
TypeScript users should use type imports for ASTNode and Visitor when not needed at runtime.
default import (v1 only)
const trastpiler = require('trastpiler');
import * as trastpiler from 'trastpiler';
In v1, the default export was an object with methods. In v2, use named imports.

Demonstrates basic traversal and transformation of a custom AST using visitor pattern.

import { traverse, transform } from 'trastpiler'; // Example AST (simple binary expression) const ast = { type: 'Program', body: [ { type: 'BinaryExpression', operator: '+', left: { type: 'NumericLiteral', value: 1 }, right: { type: 'NumericLiteral', value: 2 } } ] }; // Visitor to transform numeric literals traverse(ast, { NumericLiteral(path) { path.node.value = path.node.value * 2; } }); console.log(JSON.stringify(ast, null, 2)); // Output: left: 2, right: 4 // Using transform: returns a new AST transform(ast, { NumericLiteral(path) { path.replace({ type: 'NumericLiteral', value: 0 }); } });
Debug
Known issues
breakingv2 changes the API from default export to named exports.
fix
Replace `require('trastpiler')` with `import { traverse, transform } from 'trastpiler'`.
affects: >=2.0.0 <2.0.0
breakingVersion 2 drops support for Node <8.6. All previous versions supported Node >=6.
fix
Upgrade Node to >=8.6.
affects: >=2.0.0
gotchaPackage does not include type definitions in npm. You must add them manually or use @types/trastpiler if available.
fix
Create a declarations file or use skipLibCheck.
affects: >=1.0.0
gotchaAST node objects are mutated in place by traverse; there is no clone by default.
fix
If you need immutability, deep clone the AST before passing to traverse.
affects: >=1.0.0
Errors
Common errors & fixes
The method 'traverse' does not exist on the default export
In v2, traverse is a named export, not a property of the default export.
fix
Use named import: import { traverse } from 'trastpiler'
Cannot find module 'trastpiler'
Package not installed or wrong import path used.
fix
Run npm install trastpiler, then use correct import syntax.
TypeError: path.replace is not a function
transform expects a visitor with replace method; traverse does not have replace.
fix
Use transform instead of traverse if you need to replace nodes.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
trastpiler — npm install trastpiler · libregistry