ObjJAcornCompiler - JavaScript/Objective-J Transpiler
raw JSON → 1.0.0-10 verified Fri May 01 auth: no javascript
ObjJAcornCompiler is a tiny, fast JavaScript and Objective-J transpiler with a built-in C-like preprocessor, written in JavaScript. The current version is 1.0.0-10 (pre-release), built on an extended Acorn parser. It supports multiple ECMAScript versions (ECMA5, ECMA8, latest), loose mode, and various output options like AST generation and source maps. Key differentiators: it is the primary transpiler for the Cappuccino framework, targeting Objective-J 2.0 syntax; includes a preprocessor for macros and conditionals; and is available as an npm package. However, it cannot compile Objective-J code that depends on other files without the Objective-J runtime.
Common errors
error Cannot find module 'objj-transpiler' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install objj-transpiler@1.0.0-10' and ensure node_modules is in require path.
error SyntaxError: Unexpected token: punc (;) ↓
cause Non-Objective-J code with loose settings may cause parsing errors.
fix
Use 'loose: true' in options or ensure code is valid JavaScript/Objective-J.
error TypeError: transpiler is not a function ↓
cause Using default import incorrectly; the package exports named exports.
fix
Use 'import { transpile } from 'objj-transpiler'' instead of default import.
Warnings
breaking Version 1.0.0-10 is a pre-release; API may change without notice. ↓
fix Pin to a specific version and test thoroughly.
deprecated The --module flag is replaced by parser options; use 'module' property in options object instead. ↓
fix Pass { module: true } to transpile instead of --module.
gotcha Preprocessor only works with Objective-J code; using --no-objj disables it. ↓
fix Ensure noObjj is false if using preprocessor directives.
gotcha The transpiler cannot resolve cross-file Objective-J dependencies without the Objective-J runtime. ↓
fix Declare superclasses in the same file or use the Objective-J runtime.
Install
npm install objj-transpiler yarn add objj-transpiler pnpm add objj-transpiler Imports
- default wrong
const transpiler = require('objj-transpiler')correctimport transpiler from 'objj-transpiler' - transpile
import { transpile } from 'objj-transpiler' - Parser wrong
import Parser from 'objj-transpiler'correctimport { Parser } from 'objj-transpiler'
Quickstart
import { transpile } from 'objj-transpiler';
const code = `
#define MAX(x, y) (x > y ? x : y)
var m1 = MAX(a, b);
var m2 = MAX(14, 20);
`;
const result = transpile(code, {
module: false,
ecmaVersion: 'latest',
loose: false,
noObjj: false,
noPreprocess: false
});
console.log(result.code);
// Output:
// var m1 = a > b ? a : b;
// var m2 = 14 > 20 ? 14 : 20;