Problems bundling with Pulp

I’m wondering how to bundle compiler v. 0.15.4 code built by Pulp (v. 16.0.2), for running in the browser. Obviously Pulp isn’t meant to work directly because it still uses CommonJS modules and I get an error to that effect if I try pulp build --to ./html/Main.js.

This’s using a new Pulp project with purescript-halogen installed using bower, and the code Counter example from the Halogen Guide. But the same problem occurs with any project I’ve tried.

Invoking esbuild, as esbuild --bundle output/Main/index.js --platform=browser --outfile="html/Main.js" does work, but the resulting code doesn’t do anything at all when called from the browser. I’ve also tried using lebab on the output code, to no effect that I can see.

Pulp does build and run code which works fine in the REPL, it’s only when I try bundling it for the browser that it doesn’t work.

Thanks for your time.

(Note I’m using Pulp here because I can’t currently get Spago to work because of this error, previously discussed here.)

Hi,

I’d use esbuild (don’t think you can get pulp to work with esj-modules if you don’t implement it yourself).

By default esbuild writes everything into an object - I like to overwrite it’s name via:

esbuild ./output/Main/index.js --bundle --global-name=ps --target=chrome58,firefox57,edge18 --outfile=html/Main.js

this way this object will be called ps and you should be able to start your Halogen app in the browser via:

ps.main()

(you need the () as it’s an Effect)

Oops, yes I’d forgotten to call it.

Thank you very much.