源地图可用于Chrome扩展程序吗? [英] Do source maps work for Chrome extensions?

查看:81
本文介绍了源地图可用于Chrome扩展程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Closure编译器来创建Chrome扩展程序,并且我想使源映射可以用于调试.通过将浏览器直接指向源树中的页面,并在编译后的javascript文件的末尾添加特殊的sourceMappingURL(所有内容都在一个目录中),我可以使源映射正常工作:

I'm using the Closure compiler to create a Chrome extension and I'd like to get source maps to work for debugging. I can get source maps to work just fine by pointing the browser directly to a page in my source tree with the special sourceMappingURL added to the end of the compiled javascript file (everything is in a single directory):

debugger;document.getElementById("hello").innerHTML="Hello, world!";
//@ sourceMappingURL=background-compiled.map

但是,当我访问与扩展相同的脚本时,只能看到编译的javascript,而看不到原始源代码.我确实将Chrome调试器配置为在两种情况下均启用源映射,否则它们都将以相同的方式执行且没有错误.源映射是否仅在扩展中不起作用,或者在设置方面缺少我的东西?

But when I access the same script as an extension, I can only see the compiled javascript and not the original source. I do have the Chrome debugger configured to enable source maps in both cases, and otherwise they both execute identically with no errors. Do source maps just not work in extensions or is there something I'm missing in setting things up?

我尝试过Chrome 25 stable和Chrome 27 canary,两者的行为相同.

I've tried Chrome 25 stable and Chrome 27 canary, same behavior in both.

推荐答案

本着

In the spirit of providing answers to questions resolved in comments, Chrome previously did not support the use of source maps in extensions but this was rectified as of Chrome 29.

感谢评论员@ w00kie提交并跟踪了错误在Chromium上使用-如果您希望因自己的帮助而获得声誉,只需发表您自己的答案,我将删除它.

Thanks to the commenter, @w00kie who filed and tracked the bug on Chromium - if you wish to receive reputation for your helpful effort just post your own answer and I will delete this one.

这篇关于源地图可用于Chrome扩展程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆