Closed byteshiva closed 7 years ago
I also have same problem.
I have a fix for it, convert all each to forEach, it would work. But now I'm another set of errors.
https://github.com/byteshiva/node-uglifier/commit/ede7a7572bc8895545866f7bd643d33241a68870
This is where I'm getting error.
new Function("MOZ_SourceMap", "exports", "DEBUG", FILES.map(function(file){
return fs.readFileSync(file, "utf8");
}).join("\n\n"))(
require("source-map"),
UglifyJS,
!!global.UGLIFY_DEBUG
);
Error:
undefined:1553
throw new JS_Parse_Error(message, filename, line, col, pos);
^
Error
at new JS_Parse_Error (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1545:18)
at js_error (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1553:11)
at croak (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2092:9)
at eval (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2242:21)
at eval (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2139:24)
at if_ (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2415:44)
at eval (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2238:24)
at eval (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2139:24)
at block_ (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2432:20)
at eval (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2193:29)
I think maybe we use this library in a wrong way...
Probably maybe its because of dynamic requires.
Warning!:
unhandled require type in file: /var/www/boot.js the problematic statement: require("../serv/Q").createQ
(q) probably something fancy going on the error: probably dynamic
Warning!:
Dynamic Require
Warning!:
unhandled require type in file: /var/www/boot.js the problematic statement: require(cnfg.app.main+"/db/DBMan")
.gInst() probably something fancy going on the error: probably dynamic
Warning!:
Happens to me as well, no dynamic requires in my project. Any ideas?
Ran it like this:
var NodeUglifier = require("node-uglifier");
var nodeUglifier = new NodeUglifier("server.js");
nodeUglifier.merge().uglify();
//exporting
nodeUglifier.exportToFile("ugly.js");
I also had the same error :( /home/srijan/uglify/node_modules/node-uglifier/lib_compiled/NodeUglifier.js:151 requireStatements.each(function(o, i) { ^
TypeError: requireStatements.each is not a function
at recursiveSourceGrabber (/home/srijan/uglify/node_modules/node-uglifier/lib_compiled/NodeUglifier.js:151:27)
at NodeUglifier.merge (/home/srijan/uglify/node_modules/node-uglifier/lib_compiled/NodeUglifier.js:230:7)
at Object.
Hi the each ->forEach bug resolved.
If I run thru the below code its throws error, since the return is a object not a function. Can you explain why its not working?
Error