spago
spago copied to clipboard
Add output dir or purs-args option to spago.dhall
I was trying to change output directory to dist by setting it inside spago.dhall config file, but it seems that changing that option it is only possible using the command line.
Would it be possible to add this option to the config file? Something like this could work:
{ name = "my-project"
, dependencies = [ "effect", "console", "psci-support" ]
, output ="dist/"
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
Other alternative could be adding a purs-args setting to the config file, like this one
{ name = "my-project"
, dependencies = [ "effect", "console", "psci-support" ]
, packages = ./packages.dhall
, purs-args = [ "-o", "dist/" ]
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
Thanks in advance!
@rainbyte yes, having output in the config file would be nice! Ideally you'd want all the flags to be configurable also through the config file, but since we've been iterating quite a bit on both we haven't really been trying to sync them
Also while this sounds straightforward, there are some things that we need to pay attention to, e.g. the fact that the output folder is shared in monorepos (since #422): this means that even in the presence of multiple spago.dhall files we have only one output folder. This means that if we put the output key in the config file, we might end up with two or more different values in the same monorepo. So we should come up with a way to pick one or fail here, etc. (I don't have a solution in mind right now)
I think these are probably 2 separate things, a generic purs-args is probably useful, but output is special - it should be passed to backends also.
In fact backend-args goes along with purs-args
Should this issue remain open and track the addition of output to the new yaml config, or should a separate issue be opened for that? (It doesn't seem to be currently supported, judging by https://github.com/purescript/spago/blob/d4d2dd21f934d62308e8994da2f7f265a7885a53/spaghetto/src/Spago/Config.purs#L55)
Yes! We should definitely add this option to the WorkspaceConfig, and as a global flag on the command line
The main roadblock for this feature is that one could also pass --output inside --purs-args - we should prevent that and instead handle it only on the Spago side, to avoid unnecessary footguns for users.
We already have some machinery that can be used to detect if the use is passing a certain flag in PursArgs: https://github.com/purescript/spago/blob/d4d2dd21f934d62308e8994da2f7f265a7885a53/src/Spago/Purs.hs#L145-L148
(it's in Haskell, but it should be straightforward to port to PS)
This is now possible, see docs