Uglifyjs: Upgrading to 2.7.1 introduces cryptic errors.

Created on 17 Aug 2016  路  6Comments  路  Source: mishoo/UglifyJS

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);

Most helpful comment

@gdborton The fix is in the 2.7.2 release.

All 6 comments

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.

https://github.com/mishoo/UglifyJS2/commits/master

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabmontes picture gabmontes  路  5Comments

alexlamsl picture alexlamsl  路  5Comments

kzc picture kzc  路  5Comments

kzc picture kzc  路  3Comments

alexlamsl picture alexlamsl  路  4Comments