Comment at the end of the line of a js file causes an error
taktran opened this issue · 3 comments
taktran commented
I've tried running the app with a file which generates source maps, but it seems like uglifier fails when there is a comment on the last line of the js file. I get this error
{ [Error: Unexpected token: eof (undefined)]
pos: 3258,
col: 20,
line: 117,
filename: null,
source: '...' }
Error
at new JS_Parse_Error (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:680:9)
at token_error (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:688:9)
at unexpected (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:694:9)
at block_ (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:1006:28)
at ctor.body (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:980:25)
at function_ (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:985:15)
at expr_atom (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:1193:24)
at maybe_unary (/Users/someone/node_modules/obfuscator/node_modules/uglify-js/lib/parse.js:1363:19)
where the file to obfuscate looks something like this
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
// ...
var SomeClass = (function (_super) {
__extends(SomeClass, _super);
function SomeClass() {
_super.call(this, true);
}
return SomeClass;
})(MessageDispatcher);
module.exports = SomeClass;
//# sourceMappingURL=SomeClass.js.map
(generated from the Typescript compiler, if you are interested)
If I remove the last line, it works fine. I'm guessing the uglifier parser doesn't expect comments at the end of the file.
stephenmathieson commented
fixed and released as 0.5.3
taktran commented
Works like a charm! Thanks!
Although, I've also removed source maps, as it's pretty redundant after obfuscating =)
stephenmathieson commented
glad it's working for you!
thanks for the bug report :)