Home

Awesome

Fable.Template.Library

F# Template for create and publishing Fable Libraries

Getting started

Grab the template from nuget:

dotnet new -i "Fable.Template.Library::*"

Use the new template:

dotnet new fable-library -n CoolFableLibrary
cd CoolFableLibrary
./build.sh

Builds

MacOS/LinuxWindows
Travis BadgeBuild status
Build HistoryBuild History

Nuget

StablePrerelease
NuGet BadgeNuGet Badge

Building

Make sure the following requirements are installed in your system:

Then you just need to type ./build.cmd or ./build.sh

A note about Fable Libraries vs Fable Bindings

There are two kinds of Fable packages:

The distinction is important because Fable can read metadata from .dll assemblies (like signatures and attributes) but not executable code, for that it needs the F# sources. For JS bindings without actual code you don't need to worry as they can be distributed as any other Nuget package. However, Fable libraries need a couple of extra steps:

This is not difficult to do and usually only requires adding a tag to your project file (example), but you need to make sure all the sources get into the package with the proper directory structure. Also, take into account Fable will just make a simple XML parsing to extract the source files from the .fsproj, so you should avoid MSBuild conditionals, etc.

Because Fable will compile your sources you must be careful with compiler directives too (like #if MY_SYMBOL, etc). Though you can use this to your advantage and do some logging in debug mode (#if DEBUG). And remember also that Fable will always define the FABLE_COMPILER symbol when compiling to JS.