{"id":26506,"library":"trastpiler","title":"trastpiler","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/AgronKabashi/trastpiler","tags":["javascript","transpiler","AST"],"install":[{"cmd":"npm install trastpiler","lang":"bash","label":"npm"},{"cmd":"yarn add trastpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add trastpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v2; CommonJS require will fail unless using dynamic import.","wrong":"const traverse = require('trastpiler').traverse;","symbol":"traverse","correct":"import { traverse } from 'trastpiler'"},{"note":"transform is a named export, not a default export.","wrong":"import trastpiler from 'trastpiler'; trastpiler.transform(...)","symbol":"transform","correct":"import { transform } from 'trastpiler'"},{"note":"TypeScript users should use type imports for ASTNode and Visitor when not needed at runtime.","wrong":null,"symbol":"types","correct":"import type { ASTNode, Visitor } from 'trastpiler'"},{"note":"In v1, the default export was an object with methods. In v2, use named imports.","wrong":"import * as trastpiler from 'trastpiler';","symbol":"default import (v1 only)","correct":"const trastpiler = require('trastpiler');"}],"quickstart":{"code":"import { traverse, transform } from 'trastpiler';\n\n// Example AST (simple binary expression)\nconst ast = {\n  type: 'Program',\n  body: [\n    {\n      type: 'BinaryExpression',\n      operator: '+',\n      left: { type: 'NumericLiteral', value: 1 },\n      right: { type: 'NumericLiteral', value: 2 }\n    }\n  ]\n};\n\n// Visitor to transform numeric literals\ntraverse(ast, {\n  NumericLiteral(path) {\n    path.node.value = path.node.value * 2;\n  }\n});\n\nconsole.log(JSON.stringify(ast, null, 2));\n// Output: left: 2, right: 4\n\n// Using transform: returns a new AST\ntransform(ast, {\n  NumericLiteral(path) {\n    path.replace({ type: 'NumericLiteral', value: 0 });\n  }\n});","lang":"typescript","description":"Demonstrates basic traversal and transformation of a custom AST using visitor pattern."},"warnings":[{"fix":"Replace `require('trastpiler')` with `import { traverse, transform } from 'trastpiler'`.","message":"v2 changes the API from default export to named exports.","severity":"breaking","affected_versions":">=2.0.0 <2.0.0"},{"fix":"Upgrade Node to >=8.6.","message":"Version 2 drops support for Node <8.6. All previous versions supported Node >=6.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Create a declarations file or use skipLibCheck.","message":"Package does not include type definitions in npm. You must add them manually or use @types/trastpiler if available.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need immutability, deep clone the AST before passing to traverse.","message":"AST node objects are mutated in place by traverse; there is no clone by default.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use named import: import { traverse } from 'trastpiler'","cause":"In v2, traverse is a named export, not a property of the default export.","error":"The method 'traverse' does not exist on the default export"},{"fix":"Run npm install trastpiler, then use correct import syntax.","cause":"Package not installed or wrong import path used.","error":"Cannot find module 'trastpiler'"},{"fix":"Use transform instead of traverse if you need to replace nodes.","cause":"transform expects a visitor with replace method; traverse does not have replace.","error":"TypeError: path.replace is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}