{"id":25565,"library":"fable-compiler","title":"Fable","description":"Fable is an F# to JavaScript/TypeScript, Python, Dart, Rust, and Erlang/Elixir (BEAM) compiler. Current stable version is 2.13.0 (npm package for CLI integration) with compiler core at v5.0.0. The project releases frequently with alphas/RCs. Unlike F# Compiler Services directly, Fable translates F# into clean, readable code for multiple targets. Key differentiator: it covers F#-to-multiple-backends in one tool, with growing language support including quotations and inlining. Note: npm 'fable-compiler' package is a wrapper for JS-based tooling; the actual compiler is the dotnet tool 'fable'.","status":"active","version":"2.13.0","language":"javascript","source_language":"en","source_url":"https://github.com/fable-compiler/Fable","tags":["javascript","fable","fsharp","F#"],"install":[{"cmd":"npm install fable-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add fable-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add fable-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The npm package distributes dotnet binaries; actual compilation requires .NET SDK or dotnet tool.","package":"fable-compiler-dotnet","optional":true}],"imports":[{"note":"F# functions are exported as named exports; avoid default import.","wrong":"import fableModule from './fsharp-module'","symbol":"default and named exports (JS/TS)","correct":"import { add, multiply } from './fsharp-module'"},{"note":"When using fable-library directly, use subpath imports.","wrong":"import { FSharpRef } from 'fable-library'","symbol":"FSharpRef","correct":"import { FSharpRef } from 'fable-library/Builtins'"},{"note":"Fable.Core is separate from fable-library; ensure correct package.","wrong":"import { emitExpr } from 'fable-library'","symbol":"Fable.Core types","correct":"import { emitExpr } from 'fable-core'"}],"quickstart":{"code":"// 1. Install Fable dotnet tool:\n// > dotnet tool install --global fable\n\n// 2. Create an F# project with fable.config.json\n// Example fable.config.json:\n// {\n//   \"sourceMaps\": true,\n//   \"target\": \"javascript\"\n// }\n\n// 3. Compile F# to JavaScript:\n// > dotnet fable fsharp-project.fsproj --outDir ./output --lang js\n\n// 4. In your JavaScript:\n// import { greet } from './output/MyModule.js';\n// console.log(greet(\"World\"));","lang":"typescript","description":"Compiles an F# project to JavaScript using the dotnet tool, then imports the generated module."},"warnings":[{"fix":"Update .NET SDK to 8.0+, check migration guide for changes in generated code.","message":"Fable 5 requires .NET 8 SDK and has breaking changes in target output; references to Fable.Core libraries must be updated.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use 'dotnet fable' command instead of 'fable-compiler' CLI.","message":"The 'fable-compiler' npm package is deprecated in favor of dotnet tool; direct npm usage for compilation is discouraged.","severity":"deprecated","affected_versions":">=2.13.0"},{"fix":"Review interpolated strings in code; use format functions where specifiers are required.","message":"String interpolation format specifiers may be dropped or cause compilation errors in non-JS targets (Python, Dart, Rust, BEAM).","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Refer to Fable-friendly library replacements; use 'Fable.Core' and 'fable-library'.","message":"Fable does not support all .NET APIs; you must use Fable-specific equivalents (e.g., 'FSharp.Collections.Array' instead of 'System.Array').","severity":"gotcha","affected_versions":"all"},{"fix":"If using modulo on bigint in Python target, adjust logic to expect Python-style floored division.","message":"From v5.0.0-rc.6: Python modulo behavior for bigint changed from truncated (.NET semantics) to floored (Python semantics), breaking existing code.","severity":"breaking","affected_versions":">=5.0.0-rc.6"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: npm install fable-library","cause":"The fable-library npm package is not installed or not in node_modules.","error":"Cannot find module 'fable-library'"},{"fix":"Install .NET 8 SDK from dotnet.microsoft.com and update global.json if present.","cause":"Incompatible .NET SDK version (Fable 5 requires .NET 8+).","error":"error FS3033: The fable-compiler package is not compatible with the .NET SDK version"},{"fix":"Ensure Fable.Core is imported: import { emitExpr } from 'fable-core'","cause":"Using 'emit' macro or Fable.Core attributes without appropriate import or polyfill.","error":"Error: 'emit' is not defined (in browser)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}