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.

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.
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.
npm install onelang
yarn add onelang
pnpm add onelang

Creates a OneLang instance, adds a TypeScript source file, and transpiles it to JavaScript.

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; }'