Registry / devops / fable-compiler

fable-compiler

JSON →
library2.13.0jsnpmunverified

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'.

npm install fable-compiler
INSTALL
IMPORT
SIG · FABLE-COMPILER
F
fable-compiler
devopsjavascriptv2.13.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default and named exports (JS/TS)
import { add, multiply } from './fsharp-module'
import fableModule from './fsharp-module'
F# functions are exported as named exports; avoid default import.
FSharpRef
import { FSharpRef } from 'fable-library/Builtins'
import { FSharpRef } from 'fable-library'
When using fable-library directly, use subpath imports.
Fable.Core types
import { emitExpr } from 'fable-core'
import { emitExpr } from 'fable-library'
Fable.Core is separate from fable-library; ensure correct package.

Compiles an F# project to JavaScript using the dotnet tool, then imports the generated module.

// 1. Install Fable dotnet tool: // > dotnet tool install --global fable // 2. Create an F# project with fable.config.json // Example fable.config.json: // { // "sourceMaps": true, // "target": "javascript" // } // 3. Compile F# to JavaScript: // > dotnet fable fsharp-project.fsproj --outDir ./output --lang js // 4. In your JavaScript: // import { greet } from './output/MyModule.js'; // console.log(greet("World"));
fable --version
Debug
Known issues
breakingFable 5 requires .NET 8 SDK and has breaking changes in target output; references to Fable.Core libraries must be updated.
fix
Update .NET SDK to 8.0+, check migration guide for changes in generated code.
affects: >=5.0.0
deprecatedThe 'fable-compiler' npm package is deprecated in favor of dotnet tool; direct npm usage for compilation is discouraged.
fix
Use 'dotnet fable' command instead of 'fable-compiler' CLI.
affects: >=2.13.0
gotchaString interpolation format specifiers may be dropped or cause compilation errors in non-JS targets (Python, Dart, Rust, BEAM).
fix
Review interpolated strings in code; use format functions where specifiers are required.
affects: >=5.0.0
gotchaFable does not support all .NET APIs; you must use Fable-specific equivalents (e.g., 'FSharp.Collections.Array' instead of 'System.Array').
fix
Refer to Fable-friendly library replacements; use 'Fable.Core' and 'fable-library'.
affects: all
breakingFrom v5.0.0-rc.6: Python modulo behavior for bigint changed from truncated (.NET semantics) to floored (Python semantics), breaking existing code.
fix
If using modulo on bigint in Python target, adjust logic to expect Python-style floored division.
affects: >=5.0.0-rc.6
Errors
Common errors & fixes
Cannot find module 'fable-library'
The fable-library npm package is not installed or not in node_modules.
fix
Run: npm install fable-library
error FS3033: The fable-compiler package is not compatible with the .NET SDK version
Incompatible .NET SDK version (Fable 5 requires .NET 8+).
fix
Install .NET 8 SDK from dotnet.microsoft.com and update global.json if present.
Error: 'emit' is not defined (in browser)
Using 'emit' macro or Fable.Core attributes without appropriate import or polyfill.
fix
Ensure Fable.Core is imported: import { emitExpr } from 'fable-core'
Upgrade
Version history
2.13.0latest on npm
Audit
Dependencies
fable-compiler-dotnetoptionalThe npm package distributes dotnet binaries; actual compilation requires .NET SDK or dotnet tool.
Agent activity
2 hits · last 30 days
node
2
Resources
fable-compiler — npm install fable-compiler · libregistry