question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Uglify-JS debug prints wrong logs (with "color: #XXXXX" string)

See original GitHub issue

I use ES6 plus browserify plus Babel plus optional uglify-js.

Example to show the problem:

import debug from 'debug';

const logger = debug('device');

logger.info('browser supported [flag:%s, name:"%s", version:"%s"]', flag, name, version);

When I do NOT use uglify-js, everything is ok and the output is:

browser supported [flag:chrome, name:"Chrome", version:"64.0"]

However, when using `uglify-js, this happens:

browser supported [flag:color: #CC9933, name:"chrome", version:Chrome]

Which clearly shows that some wrong value is interpolated into the whole string and, somehow, "color: #CC9933" is printed as first %s argument.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mitra42commented, Aug 15, 2018

It would be good if this was documented, its an obscure hack to work around this issue with debug, and its unlikely people will find it in this closed issue. Even more obscure if you don’t explicitly use Uglify, just the default webpack. I had to add the following to get it to work.

    optimization: {
        minimizer: [
            new UglifyJsPlugin({
                uglifyOptions: {
                    compress: {
                        unused: false,
                        collapse_vars: false // debug has a problem in production without this.
                    }

                    //compress: false  or alternatively remove compression, it only makes about a 5% difference
                }
            })
        ]
    }
1reaction
ibccommented, Aug 16, 2018

It would be great if debug was able to work properly under default production webpack settings.

It would be even greater if libraries worked fine without depending on specific settings in other libraries. I think that’s better than “make it work for my use case, plz”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Uglify-JS debug prints wrong logs (with "color: #XXXXX ...
I use ES6 plus browserify plus Babel plus optional uglify-js. Example to show the problem: import debug from 'debug'; const logger ...
Read more >
Error Installing Discovery CLI - Secret Nodes
I get this permissions error when installing the Discovery CLI. xxxxx@DESKTOP-49GSI99:~$ npm i -g @enigmampc/discovery-cli
Read more >
Installing karma with npm on Windows 8 - node.js
I'm attempting to install karma. The machine is windows 8.1. I have node v0.12.2 installed on the system. ... I'm unsure how to...
Read more >
XSS (Cross Site Scripting) - HackTricks
In order to successfully exploit a XSS the first thing you need to find is a value controlled by you that is being...
Read more >
ReleaseNotes01x01 < System < Foswiki
Module version strings and new module dependency in 1.1.6 and 1.1.7; Wysiwyg / TinyMCE ... error.log , debug.log ) is in a month...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found