Frage

I have a Yeoman project that uses grunt-contrib-uglify on its Javascript files. When run on the Selectvizr library (pulled in using Bower) the resultant file looks like this:

!function(win){return}(this);

I think that's because Selectivizr is setup to not do anything if the browser isn't IE, so perhaps in the Grunt execution context it's doing just that?

So I want to know if it's possible to have Uglify run on Selectivizr and produce something usable?

War es hilfreich?

Lösung

Uglify processes the JavaScript for the sole purpose of optimization. Its job is to make the file super small in any way possible. To do this, it detects any non-variable conditions in the code, such as if (true) { return; }. Since true is always true, the functionality of this conditional is interpreted, and optimized for.

So, it's not an Uglify bug, since it did its job correctly. I'm not familiar with the trick Selectivizr is using, but if it works, it works.

Unfortunately, the only solution I can think of is not letting Uglify run on the file, and instead copy it over to dist/ directly.

Andere Tipps

The other solution is to comment/delete the line 32 in selectivizr.js:

if (/*@cc_on!@*/true) return;

This is the line breaking the uglify/concat task. Run again and it will work.

More on Github

var result = navigator.userAgent.match(/MSIE (\d+)/);
if (result) {
  var ieVersion = result[1];
}
else {
  return;
}

Please use the above code to fix this issue. I too got the same issue and it has been fixed after updating this line.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top