OneLang
raw JSON → 0.0.7 verified Fri May 01 auth: no javascript
OneLang is a source-to-source transpiler framework that enables writing code in multiple programming languages simultaneously. Currently at version 0.0.7, it is in early development with no stable release cadence. Unlike traditional transpilers, OneLang has its own type system and AST, and does not fully respect the syntax of input languages. It targets developers who want to generate code in multiple languages from a single source, but requires mastery of both target languages and OneLang itself. Key differentiators: self-defined rules, strong typing, and generic support, but limited maturity and documentation.
Common errors
error TypeError: OneLang is not a constructor ↓
cause Using CommonJS require instead of ESM import.
fix
Use 'import { OneLang } from 'onelang'' in an ESM context.
error Module not found: Can't resolve 'onelang' ↓
cause Package not installed or incorrect import path.
fix
Run 'npm install onelang' and ensure import path is correct.
error Error: Unsupported language 'python' ↓
cause Target language not supported by current version.
fix
Check supported languages in documentation.
Warnings
breaking Major API changes expected as project is in alpha stage. ↓
fix Pin to specific version and test upgrades.
gotcha Input language syntax may not be fully respected; custom rules apply. ↓
fix Review OneLang documentation for syntax deviations.
deprecated No stable release; API may change without notice. ↓
fix Use with caution for production.
Install
npm install onelang yarn add onelang pnpm add onelang Imports
- OneLang wrong
const onelang = require('onelang')correctimport { OneLang } from 'onelang' - Transpiler
import { Transpiler } from 'onelang' - ASTNode wrong
import { ASTNode } from 'onelang'correctimport type { ASTNode } from 'onelang'
Quickstart
import { OneLang } from 'onelang';
const oneLang = new OneLang();
oneLang.addSource('example.ts', `
function greet(name: string): string {
return 'Hello, ' + name;
}
`);
// Transpile to JavaScript
const result = oneLang.transpile('example.ts', 'javascript');
console.log(result);
// Expected output: 'function greet(name) { return "Hello, " + name; }'