Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TheAngryByrd/Fable.Template.Library
F# Template for create and publishing Fable Libraries
https://github.com/TheAngryByrd/Fable.Template.Library
dotnet-core dotnet-template fable fable-libraries fsharp javascript
Last synced: 3 days ago
JSON representation
F# Template for create and publishing Fable Libraries
- Host: GitHub
- URL: https://github.com/TheAngryByrd/Fable.Template.Library
- Owner: TheAngryByrd
- License: mit
- Created: 2017-08-18T01:10:18.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-09T14:11:23.000Z (about 3 years ago)
- Last Synced: 2024-04-14T08:53:35.734Z (7 months ago)
- Topics: dotnet-core, dotnet-template, fable, fable-libraries, fsharp, javascript
- Language: F#
- Homepage:
- Size: 120 KB
- Stars: 20
- Watchers: 4
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-fsharp-project-templates - TheAngryByrd/Fable.Template.Library - F# Template for create and publishing Fable Libraries (List / Libs)
README
# Fable.Template.Library
F# Template for create and publishing [Fable](https://github.com/fable-compiler/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/Linux | Windows
:---: | :---:
[![Travis Badge](https://travis-ci.org/TheAngryByrd/Fable.Template.Library.svg?branch=master)](https://travis-ci.org/TheAngryByrd/Fable.Template.Library) | [![Build status](https://ci.appveyor.com/api/projects/status/github/TheAngryByrd/Fable.Template.Library?svg=true)](https://ci.appveyor.com/project/TheAngryByrd/fable-template-library)
[![Build History](https://buildstats.info/travisci/chart/TheAngryByrd/Fable.Template.Library)](https://travis-ci.org/TheAngryByrd/Fable.Template.Library/builds) | [![Build History](https://buildstats.info/appveyor/chart/TheAngryByrd/fable-template-library)](https://ci.appveyor.com/project/TheAngryByrd/fable-template-library)## Nuget
Stable | Prerelease
:---: | :---:
[![NuGet Badge](https://buildstats.info/nuget/Fable.Template.Library)](https://www.nuget.org/packages/Fable.Template.Library/) | [![NuGet Badge](https://buildstats.info/nuget/Fable.Template.Library?includePreReleases=true)](https://www.nuget.org/packages/Fable.Template.Library/)## Building
Make sure the following **requirements** are installed in your system:
* [dotnet SDK](https://www.microsoft.com/net/download/core) 2.0 or higher
* [node.js](https://nodejs.org) 6.11 or higher
* [yarn](https://yarnpkg.com)
* [Mono](http://www.mono-project.com/) if you're on Linux or macOS.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:
- **JS Bindings**: These don't contain any actual code, only signatures and attributes normally generated by [ts2fable](https://www.npmjs.com/package/ts2fable). They're just used to provide a type-safe to interact with a JS library from Fable.
- **Libraries**: These contain F# code that will be compiled to JS by Fable when being referenced by a consumer project.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:
- First, the package must contain a folder named **fable** with the F# sources (and if necessary other files like JS scripts).
- The `fable` folder must contain an **.fsproj file with the same name as the Nuget package**.This is not difficult to do and usually only requires adding a tag to your project file ([example](https://github.com/fable-compiler/fable-react-native/blob/6a7cc0e5074b985ef94e49a631cb8285eb9950c8/src/Fable.React.Native.fsproj#L32-L34)), 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.