spago icon indicating copy to clipboard operation
spago copied to clipboard

bundle-* commands don't support the purs --output option

Open stkb opened this issue 6 years ago • 4 comments

If you want your output dir as anything other than /output, then using this is fine:

spago build -- --output outputDir

However this doesn't work...

spago bundle-app --to index.js -- --output outputDir

...because although it compiles the .purs files into outputDir, It then runs the purs bundle command with "output" hardcoded:

Running command: `purs bundle "output/*/*.js" -m Main --main Main -o index.js`
purs bundle: No input files.

I guess the solution would be either to detect the --output/-o args passed to the purs compiler, or possibly to add an --output option to spago itself? An entry in spago.dhall would also be nice, if you're going that way.

stkb avatar May 27 '19 06:05 stkb

@stkb great catch!

And yeah I agree with your analysis, we could either detect the --output in the args being passed to purs, or if this is too tricky we can add the --output flag to all the relevant commands, so we could just use that for everything. (I guess the question in this case would be "but what happens when we pass the --output to purs but the user also adds it as an extra argument for purs?")

I think adding adding an entry to spago.dhall is also a good idea, but a proper handling of the flags is necessary either way (because e.g. you might want to override the config value with a flag)

f-f avatar May 27 '19 12:05 f-f

Good points. This kinda opened up a can of worms 😃, but after having thought through all the options, I think it's fairly simple.

Currently, args specified after -- don't get added to the purs bundle command, only to purs compile I don't know if this was a conscious decision, but I think it should stay this way for simplicity (at least for now).

There are however two purs bundle options not currently supported by spago (--namespace and --source-maps), but I think that's ok; you can say: spago bundle-* is just a convenience command. If you want all the options, you can do spago build && purs bundle ... instead.

If there's config option for the output dir in spago.dhall, I guess I don't really also need an --output arg for spago? (Since all it does is save a few characters over -- --output, which I can use if I really need to override the config).

So it's then just detecting use of -- --output in the bundle- commands too.

I guess I could have a go at this.

stkb avatar May 27 '19 18:05 stkb

zephyr reads from output writes to dce-output; it would be nice if:

spago bundle-app -s --output dce-output

would read from the output directory to create the bundle.

coot avatar Jun 13 '20 10:06 coot

Yes! These days we even sort-of-detect when the --output option is provided as a purs arg, so we could:

  • add a output flag to spago itself
  • detect when this flag is passed as a purs argument, and issue an error/warning pointing to the --output flag instead

f-f avatar Jun 13 '20 11:06 f-f

All commands that perform a build now support the --output option

f-f avatar Sep 16 '23 10:09 f-f