Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SourceMap or X-SourceMap handling

I can't get firefox (or any browser for that matter) to recognize the X-SourceMap header. For my code. The //# SourceMappingURL comment works on the browser side for me, but I can't use it for reasons specific to my system.

I am curious under what conditions the X-SourceMap header is used to set sourcemaps, as I don't seem to be having success. I am thinking this related to how my code is fetched -- that the devtools somehow don't 'realize' that I'm fetching a javascript file for which a sourcemap should be fetched as well.

https://hg.mozilla.org/mozilla-central/rev/5a0161f8a11e seems to show how this is implemented, but it's unclear to an eye unfamiliar with this codebase how it is determined that an X-SourceMap header is acted upon.

like image 638
bcr Avatar asked Dec 11 '25 11:12

bcr


1 Answers

The X-SourceMap header support have been checked in several browsers.

Firefox 50.1 supports X-SourceMap header for JavaScript files only. The X-SourceMap header for CSS files is not supported. The SourceMap header is not supported at all.

Google Chrome 50 and Chromium 55 DevTools supports both X-SourceMap and SourceMap headers for JavaScript and CSS. Although the X-SourceMap header is deprecated a few years ago.

It seems the //# sourceMappingURL=<url> annotation has the greatest support by browsers now. If a file changing is not applicable. a solution may be to append on the fly source maps annontations to the web server respose using some kind of a web server middleware or a mitm proxy. For example connect-sourcemaps for Node.js or the like.

like image 64
Evgeniy Generalov Avatar answered Dec 14 '25 00:12

Evgeniy Generalov