United Kingdom: +44 (0)208 088 8978

Introducing SAFE Stack meta-packages

Simplifying package management in SAFE apps using the new SAFE meta-packages.

We're hiring Software Developers

Click here to find out more

In recent releases, the SAFE template has started to use meta-packages to simplify package management: SAFE.Server and SAFE.Client.

A package in a package

What is a meta-package?

In this context, a meta-package is a NuGet package that doesn't contain any of its own code. It has dependencies on several other packages so that they can be referenced in one bundle. This is quite useful for the SAFE Template which has dependencies on several packages in order to provide a framework of app development that uses them all together.

What were the problems before these meta-packages?

Given that the SAFE Template has several dependencies, we sometimes found cases where it was not clear which packages could be upgraded or removed.

Upgrading to a new version of the SAFE template could be a particularly tricky task. There were cases where various dependencies would get out of sync with each other and cause compatibility issues. At times you needed to know which versions of which packages would align with your current version of npm dependencies like React, and explicitly pin several packages to the required versions.

Meta-packages to the rescue

With these new meta-packages, all of the SAFE server and client dependencies are encapsulated into one package each, and it should be more obvious why various dependencies exist in your app. The meta-packages will be explicitly pinned but that's only two packages to keep in sync, and the version numbers are clear and obvious.

It should also be much simpler to upgrade to a new version of the SAFE Template with confidence that all of the SAFE packages are at appropriate versions.

This commit shows what the change to meta-packages looked like in paket.dependencies.

The trade-off

One possible downside of the meta-package approach is that there could be less flexibility when selecting specific packages. It might be that a certain SAFE package can be upgraded to a higher major version, but the meta-package does not allow it. If the upgrade is really required, then it's always possible to switch away from using the meta-package and going back to listing all of its dependencies. There is a balance here between flexibility and simplicity.

Extra helpers

These two packages also contain some bonus code which is often used in SAFE apps (so they aren't strictly meta-packages 🤫). This mainly consists of types and helper functions for using Fable.Remoting and Elmish more effectively and reduce some of the boilerplate code we often see in our projects.

Gratitude corner 🙏🏾

Thanks to Isaac for actually doing the work to create these meta-packages.

Enjoy!

We hope that these changes make package management much simpler in SAFE apps. If you have any issues or feedback, please open an issue or a discussion in the SAFE Template GitHub project.