Skip to content

Commit

Permalink
add sourcemap normalization to fetch loader (#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 16, 2020
1 parent f0fe5a4 commit 97621d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/features/fetch-load.js
@@ -1,4 +1,5 @@
import { errMsg } from '../err-msg.js';
import { resolveUrl } from '../common.js';
import { importMap } from '../features/import-maps.js';
import { systemJSPrototype } from '../system-core.js';

Expand Down Expand Up @@ -28,6 +29,13 @@ systemJSPrototype.instantiate = function (url, parent) {
if (!contentType || !jsContentTypeRegEx.test(contentType))
throw Error(errMsg(4, process.env.SYSTEM_PRODUCTION ? contentType : 'Unknown Content-Type "' + contentType + '", loading ' + url + (parent ? ' from ' + parent : '')));
return res.text().then(function (source) {
var sourceMappingIndex = source.lastIndexOf('//# sourceMappingURL=');
if (sourceMappingIndex > -1) {
var sourceMappingEnd = source.indexOf('\n', sourceMappingIndex);
var sourceMapping = source.slice(sourceMappingIndex, sourceMappingEnd > -1 ? sourceMappingEnd : undefined);
source += '\n//# sourceMappingURL=' + resolveUrl(sourceMapping.slice(21), url);
}
source += '\n//# sourceURL=' + url;
(0, eval)(source);
return loader.getRegister();
});
Expand Down

0 comments on commit 97621d7

Please sign in to comment.