How to force relative source map URL to follow redirect

358 views Asked by At

I have a package parse-ingredient, which has a demo page here. The demo page depends on another of my packages called numeric-quantity. The demo page just fetches the latest UMD versions of each package from UNPKG like this:

<script src="https://unpkg.com/numeric-quantity"></script>
<script src="https://unpkg.com/parse-ingredient"></script>

Each package has a source map identified as a relative URL, like this (abbreviated version of numeric-quantity.umd.js):

(function(n,d){typeof exports=="object"&&typeof module!="undefined"? // ...etc, etc, etc
//# sourceMappingURL=numeric-quantity.umd.js.map

When the demo page is loaded in Chrome, this appears in the console:

DevTools failed to load source map: Could not load content for https://unpkg.com/numeric-quantity.umd.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

Similar errors appear in other browsers. I believe this is because the browser thinks that since the original requested URL is https://unpkg.com/numeric-quantity, then the sourceMappingURL should be relative to that location, not the redirect URL that UNPKG actually resolves to (https://unpkg.com/browse/[email protected]/dist/numeric-quantity.umd.js).

Is this something I can fix with configuration? If not, is it a problem UNPKG can fix? And if not that, then is this something the browsers are actually doing wrong?

Relevant UNPKG GitHub issue

0

There are 0 answers