MCPcopy Index your code
hub / github.com/nodejs/node / maybeCacheGeneratedSourceMap

Function maybeCacheGeneratedSourceMap

lib/internal/source_map/source_map_cache.js:206–227  ·  view source on GitHub ↗

* Caches the source map if it is present in the eval'd source. * @param {string} content - the eval'd source code

(content)

Source from the content-addressed store, hash-verified

204 * @param {string} content - the eval'd source code
205 */
206function maybeCacheGeneratedSourceMap(content) {
207 const support = getSourceMapsSupport();
208 if (!(process.env.NODE_V8_COVERAGE || support.enabled || support.generated)) return;
209
210 const sourceURL = extractSourceURLMagicComment(content);
211 if (sourceURL === null) {
212 return;
213 }
214 const sourceMapURL = extractSourceMapURLMagicComment(content);
215 if (sourceMapURL === null) {
216 return;
217 }
218
219 try {
220 // Use the sourceURL as the filename, and do not create a duplicate entry.
221 maybeCacheSourceMap(sourceURL, content, null, true, undefined /** no duplicated sourceURL */, sourceMapURL);
222 } catch (err) {
223 // This can happen if the filename is not a valid URL.
224 // If we fail to cache the source map, we should not fail the whole process.
225 debug(err);
226 }
227}
228
229/**
230 * Resolves source map payload data from the source url and source map url.

Callers

nothing calls this directly

Calls 5

getSourceMapsSupportFunction · 0.85
maybeCacheSourceMapFunction · 0.85
debugFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…