parse_attached_sourcemap() — svelte Function Reference
Architecture documentation for the parse_attached_sourcemap() function in mapped_code.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD b39edb0f_ea67_1ea3_e86a_954e5131b3cd["parse_attached_sourcemap()"] d383a41d_5383_ee86_cab6_03bf1a2daf93["mapped_code.js"] b39edb0f_ea67_1ea3_e86a_954e5131b3cd -->|defined in| d383a41d_5383_ee86_cab6_03bf1a2daf93 860c55db_f911_8bca_7055_338865a9f9b0["processed_tag_to_code()"] 860c55db_f911_8bca_7055_338865a9f9b0 -->|calls| b39edb0f_ea67_1ea3_e86a_954e5131b3cd 32acb77a_d3b2_7ed6_c472_32354754ebf0["b64dec()"] b39edb0f_ea67_1ea3_e86a_954e5131b3cd -->|calls| 32acb77a_d3b2_7ed6_c472_32354754ebf0 style b39edb0f_ea67_1ea3_e86a_954e5131b3cd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/utils/mapped_code.js lines 341–387
export function parse_attached_sourcemap(processed, tag_name) {
const r_in = '[#@]\\s*sourceMappingURL\\s*=\\s*(\\S*)';
const regex =
tag_name == 'script'
? new RegExp('(?://' + r_in + ')|(?:/\\*' + r_in + '\\s*\\*/)$')
: new RegExp('/\\*' + r_in + '\\s*\\*/$');
/**
* @param {any} message
*/
function log_warning(message) {
// code_start: help to find preprocessor
const code_start =
processed.code.length < 100 ? processed.code : processed.code.slice(0, 100) + ' [...]';
// eslint-disable-next-line no-console
console.warn(`warning: ${message}. processed.code = ${JSON.stringify(code_start)}`);
}
processed.code = processed.code.replace(regex, (_, match1, match2) => {
const map_url = tag_name == 'script' ? match1 || match2 : match1;
const map_data = (map_url.match(regex_data_uri) || [])[1];
if (map_data) {
// sourceMappingURL is data URL
if (processed.map) {
log_warning(
'Not implemented. ' +
'Found sourcemap in both processed.code and processed.map. ' +
'Please update your preprocessor to return only one sourcemap.'
);
// ignore attached sourcemap
return '';
}
processed.map = b64dec(map_data); // use attached sourcemap
return ''; // remove from processed.code
}
// sourceMappingURL is path or URL
if (!processed.map) {
log_warning(
`Found sourcemap path ${JSON.stringify(
map_url
)} in processed.code, but no sourcemap data. ` +
'Please update your preprocessor to return sourcemap data directly.'
);
}
// ignore sourcemap path
return ''; // remove from processed.code
});
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does parse_attached_sourcemap() do?
parse_attached_sourcemap() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/mapped_code.js.
Where is parse_attached_sourcemap() defined?
parse_attached_sourcemap() is defined in packages/svelte/src/compiler/utils/mapped_code.js at line 341.
What does parse_attached_sourcemap() call?
parse_attached_sourcemap() calls 1 function(s): b64dec.
What calls parse_attached_sourcemap()?
parse_attached_sourcemap() is called by 1 function(s): processed_tag_to_code.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free