Registry / web-framework / ast-transpiler

ast-transpiler

JSON →
library0.0.85jsnpmunverified

ast-transpiler is a versatile source-to-source transpiler that converts code between JavaScript, TypeScript, Python, and PHP by operating on abstract syntax trees. Version 0.0.85, under active development, it provides a unified AST representation and supports transpilation of modern JavaScript (ESM/CJS) to multiple target languages. Key differentiators: single-pass transpilation, TypeScript-first with full type definitions, and extensible transpilation rules. Ideal for multi-language codebases and tooling that requires cross-language code generation.

web-frameworkserialization
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.

The package is ESM-only since v0.0.80; CommonJS require() is not supported.

import { transpile } from 'ast-transpiler'

parseSync is a named export, not a default export.

import { parseSync } from 'ast-transpiler'

TranspilerConfig is a TypeScript type and should be imported with `import type` to avoid runtime errors.

import type { TranspilerConfig } from 'ast-transpiler'

Transpiles a TypeScript function to Python using the transpile API with target language options.

import { transpile } from 'ast-transpiler'; const code = ` function add(a: number, b: number): number { return a + b; } `; async function main() { const result = await transpile({ source: code, sourceLang: 'typescript', targetLang: 'python', options: { pythonVersion: 3.9 } }); console.log(result.code); } main().catch(console.error);
ast-transpiler --version
Debug
Known footguns
breakingBreaking change in v0.0.85: `options` parameter structure changed; `pythonVersion` moved from root to nested `options.python.version`.
deprecatedDeprecated: `parseSync` is deprecated in favor of `parse` (async).
breakingBreaking change in v0.0.80: Package switched to ESM-only. `require()` calls will fail.
gotchaTypeScript types are exported only from the main entry; subpath exports do not include types.
breakingBreaking change in v0.0.70: `targetLang` option renamed from `language`.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
ahrefsbot
4
claudebot
4
gptbot
3
bytedance
3
Resources