Support IIFEs?
ben-eb opened this issue ยท 2 comments
ben-eb commented
Example compiled code without closure elimination:
Parser.prototype.data = function data() {
var _this = this;
if (!this.currToken[1].indexOf('<\'')) {
var requested = new Parser(_data.properties.filter(function (p) {
return p.name === _this.currToken[1].slice(2, -2);
})[0].syntax);
this.root.nodes = this.root.nodes.concat(requested.nodes);
this.last = this.root.nodes[this.root.nodes.length - 1];
} else {
(function () {
var range = _this.currToken[1].slice(1, -1);
var requested = _data.syntaxes.filter(function (s) {
return s.name === range;
})[0];
if (requested) {
_this.node = {
type: 'group',
nodes: new Parser(requested.syntax).nodes
};
} else {
_this.node = {
type: 'data',
value: range,
exclusive: true
};
}
})();
}
this.position++;
};
And with:
function _ref3() {
var _this = this;
function _ref19(s) {
return s.name === range;
}
if (!this.currToken[1].indexOf('<\'')) {
var requested = new Parser(_data.properties.filter(function (p) {
return p.name === _this.currToken[1].slice(2, -2);
})[0].syntax);
this.root.nodes = this.root.nodes.concat(requested.nodes);
this.last = this.root.nodes[this.root.nodes.length - 1];
} else {
(function () {
var range = _this.currToken[1].slice(1, -1);
var requested = _data.syntaxes.filter(_ref19)[0];
if (requested) {
_this.node = {
type: 'group',
nodes: new Parser(requested.syntax).nodes
};
} else {
_this.node = {
type: 'data',
value: range,
exclusive: true
};
}
})();
}
this.position++;
}
As you can see here, the reference is generated outside of the IIFE, therefore range
is no longer defined.
I'd expect that this reference to be defined inside the IIFE to fix this issue. ๐
ben-eb commented
Thanks! ๐