You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please refer to [Femto documentation](https://github.com/Zaid-Ajaj/Femto) for more information.
140
+
108
141
## Testing
109
142
110
143
It's a good idea to write unit tests for your library to make sure everything works as expected before publishing. The simplest way for that is to use a JS test runner like [Mocha](https://mochajs.org/), as in [this sample](https://github.com/fable-compiler/fable2-samples/tree/master/mocha). Or you can also use a library like [Fable.Mocha](https://github.com/Zaid-Ajaj/Fable.Mocha) containing more tools for Fable projects.
Copy file name to clipboardExpand all lines: docs/docs/your-fable-project/use-a-fable-library.md
+30-18Lines changed: 30 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@ title: Use a Fable library
3
3
layout: standard
4
4
---
5
5
6
+
## Introduction
7
+
6
8
We often use libraries using [NuGet](https://www.nuget.org/), which is the defacto .NET package manager.
7
9
8
10
So we do need libraries. And Fable proposes a great variety of libraries ready for you to use like:
@@ -19,38 +21,48 @@ There are 2 ways to call Fable libraries:
19
21
1. Reference them directly in your project file
20
22
2. Use [Paket](https://fsprojects.github.io/Paket/)
21
23
22
-
## Option 1: reference a library manually in your project file
24
+
## Install a Fable library
25
+
26
+
Fable libraries are usually published on [Nuget](https://www.nuget.org/), which is the defacto .NET package manager.
23
27
24
-
Just like `.fs` files, we can reference libraries directly in the `.fsproj` file.
28
+
You can use you favorite Nuget package manager to install them, like Nuget CLI, Paket, Visual Studio, Rider, etc.
25
29
26
-
We need to tell what library we need and what version we'd like to use. For instance for `Fable.Browser.Dom` version `1.0.0` we'll add the following node in the `.fsproj` file:
The dotnet SDK offers a CLI command to do this operation without manually editing the .fsproj. Also if you omit the version number, it will automatically pick the most recent stable version for you. For instance:
42
+
Please, refer to your Nuget package manager documentation to learn more about how to use it.
Depending on the type of library, it can happen that you also need to install a native dependency.
41
45
42
-
> Some IDEs like Visual Studio or Rider also include options in their Graphic Interface to manage Nuget packages.
46
+
For example, if you are using a project that use React, you will need to install the `react` and `react-dom` from NPM packages.
43
47
44
-
That's basically all you need to do. The build process will then automatically download the libraries for you and compile your code against them.
48
+
You need to refer to your library documentation to know if you need to install a native dependency.
45
49
46
-
> If you need to download the packages before the build (for example, to remove errors in the IDE), run the `dotnet restore` command in the folder containing the .fsproj file.
50
+
### Femto
47
51
48
-
## Option 2: use Paket!
52
+
[Femto](https://github.com/Zaid-Ajaj/Femto) is a tool that can help you install
53
+
native dependencies if the library contains Femto metadata.
49
54
50
-
The second way of adding libraries is to use the [Paket](https://fsprojects.github.io/Paket/) library manager. While it's not compulsory, it's in most cases a good choice for large projects.
55
+
Use `dotnet femto yourProject.fsproj` to check if your Fable dependencies
56
+
requirements are met.
51
57
52
-
Using Paket is clearly straightforward if you follow the [official documentation](https://fsprojects.github.io/Paket/get-started.html).
58
+
Use `dotnet femto --resolve yourProject.fsproj` to let Femto try to install
59
+
the native dependencies for you.
53
60
54
-
But in order to make things easier for you, we created a [sample](https://github.com/fable-compiler/fable2-samples/tree/master/withpaket). This is a good companion while you read the paket doc.
61
+
At the time of writing, Femto supports:
55
62
56
-
Usually getting started with Paket takes only a few minutes.
0 commit comments