hed.content); map.xScopes = parsedJSON["x-scopes"]; } } // Extend the default map object with sourceMapBaseURL, used to check further // network requests made for this sourcemap. map.sourceMapBaseURL = generatedSource.sourceMapBaseURL; if (map && map.sources) { map.sources.forEach(url => originalURLs.add(url)); } return map; } function fetchSourceMap(generatedSource, resolvedSourceMapURL, baseURL) { const existingRequest = getSourceMap(generatedSource.id); // If it has already been requested, return the request. Make sure // to do this even if sourcemapping is turned off, because // pretty-printing uses sourcemaps. // // An important behavior here is that if it's in the middle of // requesting it, all subsequent calls will block on the initial // request. if (existingRequest) { return existingRequest; } if (!generatedSource.sourceMapURL) { return null; } // Fire off the request, set it in the cache, and return it. const req = _fetch(generatedSource, resolvedSourceMapURL, baseURL); // Make sure the cached promise does not reject, because we only // want to report the error once. setSourceMap( generatedSource.id, req.catch(() => null) ); return req; } module.exports = { fetchSourceMap, hasOriginalURL, clearOriginalURLs, resolveSourceMapURL, }; PK