{"id":26089,"library":"porffor","title":"Porffor","description":"An experimental from-scratch AOT JavaScript/TypeScript compiler that compiles to WebAssembly or native binaries. Current version 0.61.13, with rapid development. Unlike JIT-based engines, it is fully ahead-of-time compiled with zero runtime prelude, and generates Wasm without using Binaryen. It supports limited JS features and is a research project not intended for production use. Key differentiators: custom Wasm binary generation, sub- and super-set of JavaScript, and ability to compile to C via its 2c sub-engine.","status":"active","version":"0.61.13","language":"javascript","source_language":"en","source_url":"https://github.com/CanadaHonk/porffor","tags":["javascript"],"install":[{"cmd":"npm install porffor","lang":"bash","label":"npm"},{"cmd":"yarn add porffor","lang":"bash","label":"yarn"},{"cmd":"pnpm add porffor","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Default parser for JavaScript source code","package":"acorn","optional":false}],"imports":[{"note":"Package is ESM-only. No named export 'Porffor'; use default import.","wrong":"const Porffor = require('porffor')","symbol":"Porffor (default)","correct":"import Porffor from 'porffor'"},{"note":"Programmatic API exports 'compile' and other functions. Not documented; check source.","wrong":"import porffor from 'porffor'","symbol":"cli (via programmatic API)","correct":"import { compile } from 'porffor'"},{"note":"Types are exported as type-only; use import type or keyof.","wrong":"import { CompileOptions } from 'porffor'","symbol":"Types (TypeScript)","correct":"import type { CompileOptions } from 'porffor'"}],"quickstart":{"code":"import Porffor from 'porffor';\n\nconst compiler = new Porffor();\nconst code = 'console.log(\"Hello, world!\");';\ntry {\n  const wasmBytes = await compiler.compile(code, { target: 'wasm' });\n  // wasmBytes is Uint8Array\n  console.log('Compilation succeeded, wasm size:', wasmBytes.length);\n} catch (err) {\n  console.error('Compilation failed:', err);\n}","lang":"typescript","description":"Demonstrates programmatic compilation of a JavaScript snippet to WebAssembly using Porffor's API."},"warnings":[{"fix":"Check the source or benchmarks for supported patterns; avoid unsupported features.","message":"Porffor supports only a limited subset of JavaScript. Many language features (e.g., classes, generators, full async) are not implemented or have bugs.","severity":"gotcha","affected_versions":"*"},{"fix":"Pin to exact version if reproducibility is needed.","message":"Versioning is unique: minor version equals Test262 pass percentage. No semantic versioning guarantees.","severity":"breaking","affected_versions":"*"},{"fix":"Explicitly specify parser via options if you rely on behavior of a specific parser.","message":"The `--parser` option default may change in future versions. Currently defaults to 'acorn'.","severity":"deprecated","affected_versions":">=0.0.0, <1.0.0"},{"fix":"Prefer compiling to Wasm; test native binaries thoroughly.","message":"Compiling to native binaries requires the experimental 2c sub-engine, which is unstable and may produce incorrect output.","severity":"gotcha","affected_versions":"*"},{"fix":"Use CLI (npx porf) instead of programmatic imports.","message":"The programmatic API is not documented and may change without notice. Use the CLI for stability.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Rewrite code to use only supported subset (e.g., no eval, no generators, limited async).","cause":"Porffor does not support the given JavaScript syntax","error":"Error: Unsupported syntax: ..."},{"fix":"Use ESM import: `import Porffor from 'porffor'`","cause":"Importing the package incorrectly (e.g., using CommonJS require)","error":"TypeError: Porffor is not a constructor"},{"fix":"Ensure acorn is installed, or specify a different parser with --parser.","cause":"Parser not installed or unsupported file extension","error":"Error: No parser was found for the given file type"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}