I installed uglify-js on my development box (windoze 7) with: "c:\Program Files\nodejs\npm.cmd" install uglify-js which ran fine. And I can run the command line tool to minify a file just fine using cygwin. But when I follow the programmatic steps to minify code within my node app I get:
FATAL ERROR: JS Allocation failed - process out of memory
To elliminate the original code being minimized as the culprit I've dropped back to a very simple test function. Here is what I have currently in my express application:
var parser = require("uglify-js").parser,
procsr = require("uglify-js").uglify;
var testcode = (function() {
return "hello world";
});
console.log("---> parse");
var ast = parser.parse(testcode);
console.log("---> ast_mangle");
ast = procsr.ast_mangle(ast);
console.log("---> ast_squeeze");
ast = procsr.ast_squeeze(ast);
console.log("---> gen_code");
var final_code = procsr.gen_code(ast);
console.log("---> compressed = " + final_code.toString());
The only lines of output from the node process that I see are as follows with parse taking perhaps 30 seconds before the 'out of memory' line appears. I am using cluster and express. Any suggestions on what could be going wrong?
node server.js
Server running on port 8999
worker 2 online
worker 1 online
---> parse
FATAL ERROR: JS Allocation failed - process out of memory
worker 1 died (1). restarting...
worker 3 online