Tagging this with discussion, because I'm not sure if doing so is problematic.
An example of the offending code:
var Just = (function () {
function Just(value0) {
this.value0 = value0;
};
Just.create = function (value0) {
return new Just(value0);
};
return Just;
})();
var Nothing = (function () {
function Nothing() {
};
Nothing.value = new Nothing();
return Nothing;
})();
The IIFE exists so that the definition of Just and Nothing do not involve statements at the module level (the create / value property assignments). In theory this makes them easier to erase, since the whole value can be eliminated, but apparently Uglify considers this to be side-effectful. I assume it takes that stance with any IIFE definition, since here only values in the internal scope of the IIFE are referenced.
I actually don't remember exactly why I did introduce the IIFE... it may purely be to avoid the module-level statements, or perhaps codegen can only produce single AST values for declarations. The latter wouldn't be too much of a problem to change, it's just a bit of refactoring.
/cc @AppShipIt @spicydonuts
Reactions are currently unavailable
Tagging this with discussion, because I'm not sure if doing so is problematic.
An example of the offending code:
The IIFE exists so that the definition of Just and Nothing do not involve statements at the module level (the create / value property assignments). In theory this makes them easier to erase, since the whole value can be eliminated, but apparently Uglify considers this to be side-effectful. I assume it takes that stance with any IIFE definition, since here only values in the internal scope of the IIFE are referenced.
I actually don't remember exactly why I did introduce the IIFE... it may purely be to avoid the module-level statements, or perhaps codegen can only produce single AST values for declarations. The latter wouldn't be too much of a problem to change, it's just a bit of refactoring.
/cc @AppShipIt @spicydonuts