How do I create local libraries in Purescript?

I’m creating a SPA in Purescript but there will be links that will point to a different SPA. I think in the micro-frontends jargon is called a Linked SPA composition. In order to keep the look and feel consistent between SPAs I want to extract common Halogen components (Navbar, footer, etc…) into a Purescript module.

But here is where I cannot find an example (maybe my fault) about how to develop a local Purescript module that won’t be published in Pursuit but that needs to be accessed by other apps.

Basically I want this structure:

.
├── common
├── main_spa
├── spa_1
└── spa_2

Where main_spa, spa_X have a build dependency through library versioning to common.

How can I accomplish this?

I’ve done this by putting the local path in packages.dhall, as below (this is an older project so the package set is outdated):

let upstream =
      https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200922/packages.dhall sha256:5edc9af74593eab8834d7e324e5868a3d258bbab75c5531d2eb770d4324a2900

in  upstream
  with locallibrary = /path/to/common/spago.dhall as Location

Then you can import it normally in spago.dhall:

{ name = "my-project"
, dependencies = [ "locallibrary" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
3 Likes