alanshaw / stripify

Browserify transform that strips console.log lines from your code
https://www.npmjs.org/package/stripify
MIT License
35 stars 11 forks source link

fix to work with Uglify #1

Closed jprichardson closed 10 years ago

jprichardson commented 10 years ago

If I remove this transform, uglify + Browserify works fine. But including this transform will cause an error on the uglified code.

alanshaw commented 10 years ago

Do you have an error message?

jprichardson commented 10 years ago

Here's part of it:

Error: Parsing file /Users/jpProjects/tmp/build/index.js: Line 15: Unexpected token ,

Here's the uglified line:

onDeviceReady: function() {
  console.log(""), console.log("device ready..."), checkPlugins(), navigator.splashscreen.hide();
}

Line 15 is the console.log line. Hope this helps some.

alanshaw commented 10 years ago

Yep, that'll break it. You'll end up with:

onDeviceReady: function() {
  , , checkPlugins(), navigator.splashscreen.hide();
}
jprichardson commented 10 years ago

Yup. Is it possible to somehow fix this so that it works with Uglify? Maybe some Uglify setting?

alanshaw commented 10 years ago

I wanted to avoid it, but it might be necessary. The fix is to replace with a constant - "0" or something. Uglify dead code eliminator will then strip that out.

Alternatively use the drop_console option https://github.com/mishoo/UglifyJS2

jprichardson commented 10 years ago

Excellent, wasn't aware of drop_console, thanks for the help :)