这已经是第二次发生了,正如您可以想象的那样,显示错误信息的调试器是调试时可能发生的最糟糕的事情。发生的情况是,当使用源映射时,调试器认为 VM 位于某一行,但实际上它还不存在,或者更糟糕的是,永远不会到达这一行。源映射是使用 Grunt uglify 插件生成的,该插件使用UglifyJS2。
一个例子:
if(something === 1){
console.log("it's something"); // debugger thinks the VM is here
else{
console.log("no it's not"); // while actually it's here
}
尽管no it's not
调试器跳到了if
我经历的另一个例子是:
var that = this;
some.functionCall(1, function(){
console.log(that); //this is where the debugger thinks the vm is
// debugger: that = undefined
// console prints nothing to that point
});
当我继续这个程序时,它console.log(that)
最终火了。
有没有其他人遇到过同样的问题?更可能是 UglifyJS2 或 Google Chrome 的问题?
Chrome 版本:38.0.2125.8 开发(64 位)
Uglify2JS:2.4.0
grunt-contrib-uglify:0.5.1