-
Notifications
You must be signed in to change notification settings - Fork 134
Description
Concern
Compiling everything in a monorepo is too slow for large monorepos. Compiling individual packages requires recompilation work.
Context
Let's say I've got a monorepo setup similar to what's in the README:
$ tree -I 'node_modules|output|package.json|yarn.lock'
.
├── app1
│ ├── spago.dhall
│ └── src
│ └── Main.purs
├── lib1
│ ├── spago.dhall
│ └── src
│ └── Lib1.purs
├── lib2
│ ├── spago.dhall
│ └── src
│ └── Lib2.purs
└── packages.dhall
6 directories, 7 filesAs the project grows, compiling everything from the top becomes slower and slower. If I wanted to iterate quickly within the lib1 package, I can move to that directory and run the build:
$ cd lib1
$ spago build --watchThis puts the output directory in lib1 and compiles everything there.
If I then wanted to iterate in lib2, I could move to that directory and run the build:
$ cd ../lib2
$ spago build --watchUnfortunately, because the output directory is in lib1, I've got to recompile everything into lib2/output.
Workaround
This can be mitigated by running
$ spago build --watch -- --output ../outputin both lib1 and lib2. They compile to a top-level output directory, and compilation results can be shared between them. If I then move to app1 or app1/test and do similar, they also get the benefits of the pre-compiled results.
Questions
- Is this the best way to address the concern, currently? If not, what's a better way?
- Could
spagomake this easier somehow?
One thing that's been in the back of my head is allowingbuildto know which package to build:$ spago build lib1spagocould do the bookkeeping of theoutputdirectory.
I'm open to other ideas as well.