adinapoli / snaplet-purescript

Automatic (re)compilation of Purescript code

Home Page:http://adinapoli.github.io/snaplet-purescript/

Repository from Github https://github.comadinapoli/snaplet-purescriptRepository from Github https://github.comadinapoli/snaplet-purescript

Speed improvement when using `pulp build` instead of `psc-bundle`

tungd opened this issue · comments

Hi, I've noticed that pulp build is much faster than psc-bundle. Especially for projects with big dependencies like Pux. Here's some number from my computer:

› time psc-bundle js/**/*.js -m Main -o js/app.js -n PS

real	0m16.674s
user	0m9.008s
sys	0m6.743s
› time pulp build --to js/bundle.js
* Building project in /Users/tung/Projects/uptime/snaplets/purs
* Build successful.
* Bundling JavaScript...
* Bundled.

real	0m4.241s
user	0m7.021s
sys	0m1.384s

I've also checked the bundle, the only different is that Pulp add a call to PS.Main.main() in the end.

› git diff --no-index js/bundle.js js/app.js
diff --git a/js/bundle.js b/js/app.js
index ffaebba..ae5c8f0 100644
--- a/js/bundle.js
+++ b/js/app.js
@@ -1375,7 +1375,8 @@ var PS = {};
   exports["text"] = $foreign.text;
 })(PS["Pux.Html.Elements"] = PS["Pux.Html.Elements"] || {});
 (function(exports) {
-    "use strict";
+  // Generated by psc version 0.10.1
+  "use strict";
   var Prelude = PS["Prelude"];
   var Control_Monad_Eff = PS["Control.Monad.Eff"];
   var Control_Monad_Eff_Exception = PS["Control.Monad.Eff.Exception"];
@@ -1431,5 +1432,4 @@ var PS = {};
   exports["main"] = main;
   exports["update"] = update;
   exports["view"] = view;
-})(PS["Main"] = PS["Main"] || {});
-PS["Main"].main();
+})(PS["Main"] = PS["Main"] || {});

Please change the compile command to pulp build, or at least make it configurable.
Thank you very much.

Hey @tungd !

I'm happy that this package is being useful to you. I'm definitely open to make the command line option configurable, whereas I'm not sure I can switch directly to use pulp build by default, and here is why: psc-bundle is quite different from pulp build, as the former allows you to specify a bunch of different modules to be aggregated together in a common namespace, which is very handy if you don't have a fat app (namely one where you invoke only the main from your JS and that's it). This is why in snaplet-purescript you can list all your modules into a file called modules.json and those will be all exported and ready to be called from your JS.

I use this snaplet at work so I can quickly test if pulp build allows for the same (or better) workflow, and if the answer is yes than by all means I will make the switch.