mishoo/UglifyJS — Issue #281: problem with defines
Author: yodaiken
Created: 2011-12-20 23:45:18+00:00
State: open

Either this is an issue with my use of defines (which just comes from the README documentation) or there is a bug:

This code:

var jsp = require('uglify-js').parser,
pro = require('uglify-js').uglify;

var asp = jsp.parse("CONSTANT;");
asp = pro.ast_mangle(asp, {
defines: {
CONSTANT: true
}
});
asp = pro.ast_squeeze(asp);
process.stdout.write(pro.gen_code(asp)+"\n");

when run using the latest `npm`-installed uglify-js gives:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object true has no method 'slice'
at walk (/Users/y/hacks/node_modules/uglify-js/lib/process.js:220:51)
at Array. (/Users/y/hacks/node_modules/uglify-js/lib/process.js:189:43)
at walk (/Users/y/hacks/node_modules/uglify-js/lib/process.js:220:36)
at doit (/Users/y/hacks/node_modules/uglify-js/lib/process.js:1960:37)
at /Users/y/hacks/node_modules/uglify-js/lib/process.js:1977:72
at redo_if (/Users/y/hacks/node_modules/uglify-js/lib/process.js:800:30)
at Array. (/Users/y/hacks/node_modules/uglify-js/lib/process.js:844:43)
at walk (/Users/y/hacks/node_modules/uglify-js/lib/process.js:215:47)
at /Users/y/hacks/node_modules/uglify-js/lib/process.js:855:24
at Object.with_walkers (/Users/y/hacks/node_modules/uglify-js/lib/process.js:243:27)