Registry / web-framework / fable-compiler-netcore

fable-compiler-netcore

JSON →
library0.7.42jsnpmunverified

Fable is an F# to JavaScript compiler that leverages the F# compiler service and Babel to emit clean, readable JavaScript. It compiles F# source code directly (no .NET bytecode), includes a minimal runtime (~20KB min+gzip), and integrates with the JavaScript ecosystem (ES6 modules, npm, Webpack). Current stable version is 5.0.0 (released 2024-08). Release cadence: major versions (4.x, 5.x) have been stable for years; pre-release RCs and alphas are frequent (multiple per month). Differentiators: F# fidelity (most F# core library, quotations, type providers), multi-target (JS, TS, Python, Dart, Rust, Erlang/BEAM), and no runtime overhead.

npm install fable-compiler-netcore
INSTALL
IMPORT
SIG · FABLE-COMPILER-NET
F
fable-compiler-netcore
web-frameworkjavascriptv0.7.42
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.

fable-compiler
npm install -g fable-compiler
npm install fable
The npm package is named fable-compiler, not fable. The CLI command is just 'fable'.
Fable.Core
open Fable.Core
open Fable
Core library for attributes like [<Import>], [<Emit>], etc. Separate NuGet package.
Fable.React
#r "nuget: Fable.React"
#r "nuget: React"
React bindings for Fable. Must reference the Fable-specific package.

Shows minimal F# project setup with Fable, including fsproj, Fable.Core reference, and CLI compilation.

// Create a simple F# project // 1. Create project.fsproj with: // <Project Sdk="Microsoft.NET.Sdk"> // <PropertyGroup> // <TargetFramework>net8.0</TargetFramework> // </PropertyGroup> // <ItemGroup> // <Compile Include="Program.fs" /> // <PackageReference Include="Fable.Core" Version="4.0.0-beta-*" /> // </ItemGroup> // </Project> // 2. Create Program.fs with: module Program open Fable.Core [<EntryPoint>] let main argv = printfn "Hello from Fable!" 0 // 3. Compile: // dotnet fable --lang JavaScript --outDir output // 4. Run output/Program.js with Node
dotnet fable --version
Debug
Known issues
breakingOptions are erased — "None" becomes null/undefined, "Some x" becomes x.
fix
Use pattern matching or Option module functions instead of null checks on options.
affects: >=1.0
breakingFable 3.0 renamed package from "fable-compiler" to "fable"? Actually the package is still "fable-compiler"; the CLI command is "fable".
fix
Install with 'npm install -g fable-compiler'; run with 'fable'.
affects: >=3.0
gotchaFable target languages: JavaScript (default), TypeScript, Python, Dart, Rust, Erlang/BEAM. Use --lang flag.
fix
Specify target language explicitly: 'dotnet fable --lang TypeScript'.
affects: >=4.0
deprecatedLegacy Fable 1.x and 2.x are obsolete; .NET Framework requirement vs .NET Core/5+.
fix
Upgrade to Fable 4.x or 5.x and use .NET SDK (net8.0+).
affects: <3.0
gotchaFable 5.0.0-rc released Aug 2024; stable 5.0.0 is final. Ensure compatibility with F# 8 and .NET 8.
fix
Use F# 8 and .NET 8 SDK for Fable 5.0+.
affects: >=5.0.0
breakingFable 5.0.0 final: Python target now uses len() instead of .length for ResizeArray (breaking).
fix
Update Python-specific code expecting .length property; use len() or .Length (which maps to len()).
affects: >=5.0.0
Errors
Common errors & fixes
fable: command not found
Installed package 'fable' instead of 'fable-compiler'.
fix
Install fable-compiler: npm install -g fable-compiler
Cannot find module 'fable-compiler'
Running 'fable' before installing, or installed locally not globally.
fix
Install globally: npm install -g fable-compiler, or use npx: npx fable-compiler
The type 'Fable.Core.ImportAttribute' is not defined
Missing reference to Fable.Core NuGet package.
fix
Add <PackageReference Include="Fable.Core" Version="*" /> to .fsproj
Upgrade
Version history
0.7.42latest on npm
Audit
Dependencies
babel-corerequiredFable uses Babel for code generation and source maps.
fsharprequiredRequires F# compiler (fsc.exe) installed on system.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
fable-compiler-netcore — npm install fable-compiler-netcore · libregistry