I’ve been having an issue with sourcemaps but I have found the reason why. The docs kinda state it but don’t state it clearly enough that
#sourceMappingURL absolutely must be present in your dist JS file. After browsing other topics here, and, in particular, finding the following answer:
I am happy that I’m the one doing it wrong. Sentry basically doesn’t support what Webpack calls “hidden sourcemaps” (see Webpack v1 docs and Webpack v2 docs). The way Webpack produces these is to produce a sourcemap as normal but to not include the
#sourceMappingURL declaration, thus effectively severing the link between dist and sourcemap.
I was rather hoping, however, that I could still use these with Sentry. Basically uploading the distibution JS to my website and the sourcemap to Sentry as an artifact. But it seems that Sentry requires the mapping URL declaration. I get it (kinda) - as @benvinegar said in the quoted reply, there’s no presumption of mapping unless explicitly stated.
So, my question: is it likely/possible that Sentry would ever support this in any form?
I imagine that if Sentry did not wish to use any assumptions, we could use an extra parameter on the Sentry API to make a given soucemap refer to a given dist JS file.
sentry-cli already treats sourcemaps differently to other artifacts (presumably for the
--validate flag only, but maybe other stuff?) so it’s not a crazy stretch to assume that Sentry could support this with not-too-great effort, right?
FWIW I am aware that I can easily get around this issue by producing a normal sourcemap (i.e. leaving that declaration in), and then simply not uploading the sourcemap to my web server but still uploading it to Sentry. This is pretty good except that it’s not 100% ideal. Anyone opening devtools on the production site will produce some 404s for the sourcemap. Not the end of the world I know, but as I said, not 100% ideal either.