I'm facing some weird issues with gulp-sourcemaps and gulp-uglify working together, basically, we use the gulp-uglify to minify our code and gulp-sourcemaps to create the source map of the project to be debugged the JS code at the console.
So today, while debugging I noticed Google Chrome seemed to was executing an if statement even I knew the condition didn't retrieve a true value, I had my if like this if ('string-A' === 'string-B') { image.onerror = null } So, I added a breakpoint at the onerror assignment and chrome was pausing my code there. A very weird case.
I started debugging so I changed the source code for the minified file, to check if the minified code was causing the issue, this is the block of code minified:
l === i && i !== t ? o ? a.src = n : e(a) : l === n ? e(a) : l === t && (a.onerror = null)
I don't see any issues there, I checked with some new breakpoints, and highlighted piece of code is never executed because l === t retrives false as it should do. Then I used again the source file just to verify that the onerror value never changed for the image as I thought, so it seems to be an error with the Chrome core while trying to match the minified file with the source. It seems that Chrome stops at a random place.
Is there a way to avoid these issues? I ask this because it took us a long time to test and actually the output is the same, we just validated it was not an issue in our side.
In my case, we had some comments were not removed before from the source code, so It was the reason source and the minified file was not matching.