Skip to content

Commit a8e3099

Browse files
author
Maxime Mangel
committed
Add Fable.Packages link + documentation on how to setup a Fable package to make it compatible
1 parent 25639a7 commit a8e3099

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

docs/docs/your-fable-project/author-a-fable-library.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ title: Author a Fable library
33
layout: standard
44
---
55

6-
To write a library that can be used in Fable you only need to fulfill a few conditions:
6+
## Requirements
7+
8+
To write a library that can be used in Fable you need to fulfill a few conditions:
79

810
- Don't use FSharp.Core/BCL APIs that are not [compatible with Fable](../dotnet/compatibility.html).
911
- Keep a simple `.fsproj` file: don't use MSBuild conditions or similar.
@@ -18,7 +20,89 @@ The last point may sound complicated but it's only a matter of adding a couple o
1820
</ItemGroup>
1921
```
2022

21-
That's all it takes to make your library compatible with Fable! In order to publish the package to Nuget check [the Microsoft documentation](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli) or alternatively you can also [use Fake](https://fake.build/dotnet-nuget.html#Creating-NuGet-packages).
23+
In order to publish the package to Nuget check [the Microsoft documentation](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli) or alternatively you can also [use Fake](https://fake.build/dotnet-nuget.html#Creating-NuGet-packages).
24+
25+
## Make your package discoverable
26+
27+
[Fable.Packages](https://fable.io/packages/) is a tool making it easy for users to search for Fable packages.
28+
29+
To make your packages listed on Fable.Packages, you need to add some tags to your `.fsproj`.
30+
31+
<ul class="textual-steps">
32+
33+
<li>
34+
35+
**All Fable** packages must have the `fable` tag.
36+
37+
</li>
38+
39+
<li>
40+
41+
Specify what kind of package you are publishing.
42+
43+
A fable package can be one of the following:
44+
45+
- `fable-library`: A library that can be used in Fable
46+
47+
Examples of libraries could be [Fable.Promise](https://github.com/fable-compiler/fable-promise/), [Elmish](https://elmish.github.io/), [Thoth.Json](https://thoth-org.github.io//Thoth.Json/), [Feliz](https://zaid-ajaj.github.io/Feliz/)
48+
49+
<div></div> <!-- Force a space to improve visual -->
50+
51+
- `fable-binding`: The package consist of a set of API to make a native library available
52+
53+
For example:
54+
55+
- A package which makes an NPM package API available
56+
- A package which makes the Browser API available
57+
- A package which makes a cargo package API available
58+
59+
</li>
60+
61+
<li>
62+
63+
Specify which targets are supported by your package.
64+
65+
Choose one or more of the following tags:
66+
67+
- `fable-dart`: Dart is supported by the package
68+
- `fable-dotnet`: .NET is supported by the package
69+
- `fable-javascript`: JavaScript is supported by the package
70+
- `fable-python`: Python is supported by the package
71+
- `fable-rust`: Rust is supported by the package
72+
- `fable-all`: Package is compatible with all Fable targets.
73+
74+
:::warning
75+
A package can only be compatible with all the target if it depends only packages that are also compatible with all the targets.
76+
77+
A package compatible with all the targets cannot be a binding as bindings are target specific.
78+
:::
79+
80+
Example:
81+
82+
If your package support only JavaScript you need to use `fable-javascript`
83+
84+
If your package support both JavaScript and Python, you need to use `fable-javascript` and `fable-python`
85+
86+
</li>
87+
88+
</ul>
89+
90+
Examples:
91+
92+
If your package is a binding which target JavaScript you need to write:
93+
94+
```xml
95+
<PropertyGroup>
96+
<PackageTags>fable;fable-binding;fable-javascript</PackageTags>
97+
```
98+
99+
If your package is a library which target JavaScript and Python you need to write:
100+
101+
```xml
102+
<PropertyGroup>
103+
<PackageTags>fable;fable-library;fable-javascript;fable-python</PackageTags>
104+
</PropertyGroup>
105+
```
22106

23107
## Testing
24108

nacara.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"label": "Documentation",
1414
"pinned": true
1515
},
16+
{
17+
"url": "/packages/",
18+
"label": "Packages"
19+
},
1620
{
1721
"url": "/repl/",
1822
"label": "Try"

0 commit comments

Comments
 (0)