{"id":26663,"library":"xcompile","title":"XCompile","description":"XCompile is a robust tokenizer, parser, and transpiler for translating between programming languages. Current stable version is 0.6.1, released in 2025 with improved Clang parsing, XIR JSON target, and TypeScript emitter enhancements. It uses a custom intermediate representation (XIR) and supports translating Clang AST JSON into TypeScript. Key differentiators include native Clang bindings, ESM-only support (Node >= 20), and built-in CLI. Release cadence is irregular with major features added incrementally.","status":"active","version":"0.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/james-pre/xcompile","tags":["javascript","typescript"],"install":[{"cmd":"npm install xcompile","lang":"bash","label":"npm"},{"cmd":"yarn add xcompile","lang":"bash","label":"yarn"},{"cmd":"pnpm add xcompile","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only since v0.6.0; CommonJS require will fail.","wrong":"const xcompile = require('xcompile')","symbol":"xcompile","correct":"import { xcompile } from 'xcompile'"},{"note":"XCompile is a named export, not a default export.","wrong":"import XCompile from 'xcompile'","symbol":"XCompile","correct":"import { XCompile } from 'xcompile'"},{"note":"clang module is exported from the main package since v0.5.0.","wrong":"import { clang } from 'xcompile/clang'","symbol":"clang","correct":"import { clang } from 'xcompile'"}],"quickstart":{"code":"import { xcompile, XCompile } from 'xcompile';\n\nconst xc = new XCompile();\nconst source = `int add(int a, int b) { return a + b; }`;\nconst result = xc.transpile(source, { from: 'c', to: 'ts' });\nconsole.log(result.code);\n// Expected output: function add(a: number, b: number): number { return a + b; }","lang":"typescript","description":"Shows basic C to TypeScript transpilation using XCompile class and transpile method."},"warnings":[{"fix":"Use clang.parseRaw for old behavior or update to new clang.parse API.","message":"Renamed clang.parse to clang.parseRaw and added new clang.parse in v0.5.0","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Existing tokenizer/parser APIs are removed; use new XIR-based pipeline.","message":"Removed custom tokenizer and parser in v0.4.0; replaced with XIR and Clang AST JSON","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Update API calls to use camelCase property names.","message":"Changed snake_case to camelCase in v0.3.0","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Avoid using deprecated options; check current API documentation.","message":"Options like config.compress are deprecated since v0.3.0; removed in v0.4.0","severity":"deprecated","affected_versions":">=0.3.0 <0.4.0"},{"fix":"Use ES modules or upgrade Node to >=20.","message":"ESM-only package; require() fails on Node < 20","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Pin to a specific minor version if type stability is required.","message":"TypeScript types shipped but may not be stable across minor versions","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import syntax or set type: module in package.json","cause":"Package is ESM-only; using CommonJS require()","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use named import: import { xcompile } from 'xcompile'","cause":"Default import used when only named export exists","error":"TypeError: xcompile is not a function"},{"fix":"Run npm install xcompile and use correct import path 'xcompile'","cause":"Package not installed or incorrect import path","error":"Error: Cannot find module 'xcompile'"},{"fix":"Use clang.parseRaw or upgrade to new clang.parse API","cause":"API change in v0.5.0: clang.parse renamed to clang.parseRaw","error":"TypeError: clang.parse is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}