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 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
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.
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`
Is there a way to either get chrome to override the directory or tell parcel to create those urls?
Most JavaScript and CSS sources are usually minified and source maps serve as a memory map to the compressed files. It's generally a good practice to minify and combine your assets (Javascript & CSS) when deploying to production.
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.
Try using inline sourcemaps during development. Chrome won't load Chrome extension sourcemap files, but inline sourcemaps do work.
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.
Here are two relevant Chromium bugs tracking this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With