purescript-contrib/purescript-argonaut-core

Problem with `psc-bundle`

menelaos opened this issue · 1 comments

As mentioned in purescript/purescript#2290, there is a problem with psc-bundle which sometimes removes "dead code" that is actually required.

Steps to reproduce:

  • git clone https://github.com/purescript-contrib/purescript-argonaut-core
  • cd purescript-argonaut-core
  • bower install
  • psc "src/**/*.purs" "bower_components/purescript-*/src/**/*.purs" "test/**/*.purs"
  • psc-bundle "output/**/*.js" --module Test.Main --main Test.Main | node

This will result in a ReferenceError:

        var akeys = objKeys(a);
                    ^

ReferenceError: objKeys is not defined

This issue should probably be fixed in psc-bundle but for the time being the error can be averted by changing the following code in Data/Argonaut/Core.js

function _compare(EQ, GT, LT, a, b) {
  // Body that uses `objKeys`
}
exports._compare = _compare;

to

exports._compare = function _compare (EQ, GT, LT, a, b) {
  // Body that uses `objKeys`
};