Firefly Compiler

raw JSON →
0.6.19 verified Fri May 01 auth: no javascript

A compile-to-JavaScript language with colorless async/await and type classes. Current stable version is 0.6.19, with frequent releases (multiple self-hosting milestones). Self-hosting compiler written in JavaScript compiles itself in ~1.2 seconds. Differentiators: colorless async (no explicit async/await markers), type classes (similar to Haskell), and self-hosting transpiler approach. Targets Node.js >=18. Active development with contributions from multiple developers.

error ERR_REQUIRE_ESM: require() of ES Module /path/to/firefly-compiler/index.js from /path/to/your/file.js not supported.
cause Package is ESM-only; CommonJS require() is not allowed.
fix
Replace require('firefly-compiler') with import firefly from 'firefly-compiler' or switch to dynamic import.
error SyntaxError: Unexpected token 'export'
cause Node.js version <18 does not support ESM syntax without --experimental-modules flag.
fix
Update Node.js to >=18 or use a transpiler like Babel.
error Error: Cannot find module 'firefly-compiler'
cause Package not installed or not in node_modules.
fix
Run npm install firefly-compiler (requires Node.js >=18).
breaking Node.js >=18 required; older versions will fail with syntax errors due to ESM.
fix Upgrade Node.js to version 18 or higher.
gotcha Package is ESM-only; using require() will throw ERR_REQUIRE_ESM.
fix Use import statements instead of require() in your project, or switch to dynamic import.
gotcha Compilation may fail if source contains unsupported features from newer Firefly versions.
fix Check changelog for breaking syntax changes. Use --version flag to see compiler version.
deprecated Older versions (<0.5) used a different API; compile function may not exist.
fix Upgrade to latest version and use compile() from the package.
npm install firefly-compiler
yarn add firefly-compiler
pnpm add firefly-compiler

Compiles a simple Firefly snippet that prints a message, then executes the generated JavaScript.

import { compile } from 'firefly-compiler';

const source = `
print("Hello from Firefly!")
`;

async function main() {
  const { code } = await compile(source, { target: 'es2022' });
  eval(code);
}

main().catch(console.error);