Skip to content

Commit 8563932

Browse files
authored
Merge pull request #371 from SAFE-Stack/remove-meta-packages
Remove meta packages
2 parents c5b9e12 + 6d2157c commit 8563932

File tree

2 files changed

+152
-1
lines changed

2 files changed

+152
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# How do I opt out of Meta packages?
2+
3+
By default, projects created using the SAFE template depend on the SAFE.Meta packages. This package provides functionality, but mainly exists to simplify dependency management; a standard SAFE app might very well exist with only two dependencies, being the SAFE.Client and SAFE.Server packages.
4+
5+
If your app starts deviating a lot from the standard SAFE app, you might want to uninstall the SAFE.Meta packages, so that you can remove packages it pulls in. This recipe explains how to do so.
6+
7+
## 1. Add the SAFE dependencies explicitly to your SAFE app.
8+
9+
Add the packages that SAFE.Meta relies on as explicit dependencies:
10+
11+
> Instead of using the snippets here, you can also copy these sections from the [SAFE.Meta repository](https://github.com/SAFE-Stack/SAFE.Meta), to make sure you have the most up-to-date versions
12+
13+
```diff title="paket.dependencies"
14+
source https://api.nuget.org/v3/index.json
15+
framework: net8.0
16+
storage: none
17+
18+
nuget Expecto ~> 9
19+
20+
- nuget SAFE.Server ~> 5
21+
- nuget SAFE.Client ~> 5
22+
+ nuget FSharp.Core ~> 8
23+
+
24+
+ nuget Fable.Remoting.Giraffe ~> 5
25+
+ nuget Saturn ~> 0
26+
+
27+
+ nuget Fable.Core ~> 4
28+
+ nuget Fable.Elmish ~> 4
29+
+ nuget Fable.Elmish.React ~> 4
30+
+ nuget Fable.Elmish.HMR ~> 7
31+
+ nuget Fable.Mocha ~> 2
32+
+ nuget Fable.Remoting.Client ~> 7
33+
+ nuget Fable.SimpleJson
34+
+ nuget Feliz ~> 2
35+
36+
nuget Fake.Core.Target ~> 5
37+
nuget Fake.IO.FileSystem ~> 5
38+
nuget Farmer ~> 1
39+
```
40+
41+
```diff title="src/Client/paket.references"
42+
- SAFE.Client
43+
+ FSharp.Core
44+
+ Fable.Core
45+
+ Fable.Elmish
46+
+ Fable.Elmish.React
47+
+ Fable.Elmish.HMR
48+
+ Fable.Mocha
49+
+ Fable.Remoting.Client
50+
+ Feliz
51+
+ Fable.SimpleJson
52+
```
53+
54+
```diff title="src/Server/paket.references"
55+
- Safe.Server
56+
+ FSharp.Core
57+
+ Saturn
58+
+ Fable.Remoting.Giraffe
59+
```
60+
61+
And re-install the paket dependencies
62+
63+
```bash
64+
dotnet paket install
65+
```
66+
67+
This will remove the Meta packages from paket.lock, and may, depending on how up-to-date your project is, update any out-of-date packages.
68+
69+
```diff title="paket.lock"
70+
...
71+
- SAFE.Client (5.1.1)
72+
- Fable.Core (>= 4.5 < 5.0)
73+
- Fable.Elmish (>= 4.2 < 5.0)
74+
- Fable.Elmish.HMR (>= 7.0 < 8.0)
75+
- Fable.Elmish.React (>= 4.0 < 5.0)
76+
- Fable.Mocha (>= 2.17 < 3.0)
77+
- Fable.Remoting.Client (>= 7.32 < 8.0)
78+
- Fable.SimpleJson (>= 3.24)
79+
- Feliz (>= 2.9 < 3.0)
80+
- FSharp.Core (>= 8.0.403 < 9.0)
81+
- SAFE.Server (5.1.1)
82+
- Fable.Remoting.Giraffe (>= 5.21 < 6.0)
83+
- FSharp.Core (>= 8.0.403 < 9.0)
84+
- Saturn (>= 0.17 < 1.0)
85+
...
86+
```
87+
88+
## 2. Copy SAFE.Meta functionality into your own project
89+
90+
If you are using any of the code supplied by the Meta packages, you need to copy the code into your own project:
91+
92+
Navigate to the [SAFE.Meta repository](https://github.com/SAFE-Stack/SAFE.Meta) and copy the following files into your repository:
93+
94+
* src/SAFE.Client/SAFE.fs -> src/Client/SAFE.fs
95+
* src/SAFE.Server/SAFE.fs -> src/Server/SAFE.fs
96+
97+
and update the corresponding project files:
98+
99+
```diff title="Client.fsproj"
100+
<?xml version="1.0" encoding="utf-8"?>
101+
<Project Sdk="Microsoft.NET.Sdk">
102+
<PropertyGroup>
103+
<TargetFramework>net8.0</TargetFramework>
104+
<DefineConstants>FABLE_COMPILER</DefineConstants>
105+
</PropertyGroup>
106+
<ItemGroup>
107+
<None Include="postcss.config.js" />
108+
<None Include="tailwind.config.js" />
109+
<None Include="index.html" />
110+
<None Include="paket.references" />
111+
+ <Compile Include="SAFE.fs" />
112+
<Compile Include="Index.fs" />
113+
<Compile Include="App.fs" />
114+
<None Include="vite.config.mts" />
115+
</ItemGroup>
116+
<ItemGroup>
117+
<ProjectReference Include="..\Shared\Shared.fsproj" />
118+
</ItemGroup>
119+
<Import Project="..\..\.paket\Paket.Restore.targets" />
120+
</Project>
121+
```
122+
123+
```diff title="Server.fsproj"
124+
<?xml version="1.0" encoding="utf-8"?>
125+
<Project Sdk="Microsoft.NET.Sdk.Web">
126+
<PropertyGroup>
127+
<OutputType>Exe</OutputType>
128+
<TargetFramework>net8.0</TargetFramework>
129+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
130+
</PropertyGroup>
131+
<ItemGroup>
132+
<None Include="paket.references" />
133+
+ <Compile Include="SAFE.fs" />
134+
<Compile Include="Server.fs" />
135+
</ItemGroup>
136+
<ItemGroup>
137+
<ProjectReference Include="..\Shared\Shared.fsproj" />
138+
</ItemGroup>
139+
<Import Project="..\..\.paket\Paket.Restore.targets" />
140+
</Project>
141+
```
142+
143+
## 3. Use Paket to remove any redundant dependencies
144+
145+
You're now able to remove any dependencies you do not need with Paket.
146+
147+
```bash
148+
dotnet paket remove <package-name>
149+
```

mkdocs.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ nav:
115115
- Migrate to Paket from NuGet: "recipes/package-management/migrate-to-paket.md"
116116
- Migrate to NuGet from Paket: "recipes/package-management/migrate-to-nuget.md"
117117
- Sync NuGet and NPM Packages: "recipes/package-management/sync-nuget-and-npm-packages.md"
118+
- Opt out of META packages: "recipes/package-management/opt-out-of-meta-packages.md"
119+
118120
- Patterns:
119121
- Use Dependency Injection: "recipes/patterns/add-dependency-injection.md"
120122
- Client / Server:
@@ -186,4 +188,4 @@ nav:
186188
- Add a NuGet package to the Client: "v4-recipes/package-management/add-nuget-package-to-client.md"
187189
- Migrate to Paket from NuGet: "v4-recipes/package-management/migrate-to-paket.md"
188190
- Migrate to NuGet from Paket: "v4-recipes/package-management/migrate-to-nuget.md"
189-
- Sync NuGet and NPM Packages: "v4-recipes/package-management/sync-nuget-and-npm-packages.md"
191+
- Sync NuGet and NPM Packages: "v4-recipes/package-management/sync-nuget-and-npm-packages.md"

0 commit comments

Comments
 (0)