我可以在Chrome扩展程序中启用源地图吗? [英] Can I enable sourcemaps in a chrome extension?
问题描述
我正在做一些测试开发,并使用Svelte和ParcelJS创建一个Chrome扩展,并希望在chrome开发工具中查看源地图.但是,当查看任何页面时,我只能看到捆绑的代码,看到此错误:
I'm doing some test development and creating a Chrome extension using Svelte and ParcelJS and would like to see the sourcemaps in chrome dev tools. When looking at any page however I can only see the bundled code see this error:
DevTools无法加载SourceMap:无法加载chrome-extension://debafkiakedogoflaalmbbfbbccnfbib/Background/index.js.map:HTTP错误:状态代码404,net :: ERR_UNKNOWN_URL_SCHEME
DevTools failed to load SourceMap: Could not load content for chrome-extension://debafkiakedogoflaalmbbfbbccnfbib/Background/index.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
似乎加载程序不喜欢 chrome-extension
url方案.我尝试将'dist'添加为替代目录,但是无论加载源地图,似乎都将其忽略并仍使用"chrome-extension"方案.
It seems the loader does not like the chrome-extension
url scheme. I've tried adding 'dist' as an override directory, but whatever loads the sourcemaps seems to ignore it
and still uses the 'chrome-extension` scheme.
我可以通过将URL手动更改为另一个模式( file:///
url或在dist目录中运行简单的http服务器并使用)来使其工作http://
网址:
I am able to get it working by manually changing the url to another schema, either a file:///
url or running a simple http server in the dist directory and using an http://
url:
//# sourceMappingURL=file:///c:/git/svelte-extension/dist//Background/index.js.map`
//# sourceMappingURL=http://localhost:8080/Background/index.js.map`
是否有办法让chrome覆盖目录或告诉宗地创建这些URL?
Is there a way to either get chrome to override the directory or tell parcel to create those urls?
推荐答案
在开发过程中尝试使用内联源地图.Chrome不会加载Chrome扩展源地图文件,但是内联源地图可以正常工作.
Try using inline sourcemaps during development. Chrome won't load Chrome extension sourcemap files, but inline sourcemaps do work.
Chrome一直无声地无法通过 chrome-extension://
URL方案加载源地图文件. Chrome v80 开始报告 DevTools无法加载SourceMap
错误.
Chrome has always silently failed to load sourcemap files from the chrome-extension://
URL scheme. Chrome v80 started reporting the DevTools failed to load SourceMap
error.
这可能很快就会改变,因为在作品中有一个修复程序.一些安全方面的顾虑阻止了此操作,因此请保持双手交叉.
This may change soon, as there is a fix in the works. Some security concerns are holding this back, so keep your fingers crossed.
以下是两个与此相关的Chromium错误:
Here are two relevant Chromium bugs tracking this:
- https://bugs.chromium.org/p/铬/问题/细节?id = 1052872#c14
- https://bugs.chromium.org/p/chromium/问题/详细信息?id = 1053535
这篇关于我可以在Chrome扩展程序中启用源地图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!