It took a little while to debug this, but basically upgrading to 2.7.1 introduced some bugs in our code.
I generated a quick test for reproduction.
// this is valid js
(function() {
return function(){console.log('test')};
})()()
// 2.7.0
!function(){return function(){console.log("test")}}()();
// 2.7.1
(!function(){return function(){console.log("test")}}())();
2.7.1 throws with VM68:52 Uncaught TypeError: (!(intermediate value)(...)) is not a function
Fiddle containing the above.
How I generated the minified code:
npm install uglify-js@<version>; node test.js
test.js
const uglify = require("uglify-js")
const code = `
(function() {
return function(){console.log('test')};
})()()
`;
const result = uglify.minify(code, { fromString: true });
console.log(result.code);
Use -c negate_iife=false as a workaround:
$ uglifyjs -V
uglify-js 2.7.1
$ echo "(function(){return function(){console.log('test')};})()()" | uglifyjs -c negate_iife=false | node
test
Bug introduced in fb049d3a81b744a5facf1f032b8b2815c410f178
Fix: #1255
@gdborton The fix is in the 2.7.2 release.
@kzc thanks for the fast response on this!
You guys probably will want to grab v2.7.3 which was just released. Bugs often come in pairs.
Most helpful comment
@gdborton The fix is in the 2.7.2 release.