extractScriptTags() — astro Function Reference
Architecture documentation for the extractScriptTags() function in parseJS.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ec8d4bbf_da51_efdd_06cc_5efbc5901fc5["extractScriptTags()"] 2208f162_1b21_d542_51aa_98ca1eda9260["parseJS.ts"] ec8d4bbf_da51_efdd_06cc_5efbc5901fc5 -->|defined in| 2208f162_1b21_d542_51aa_98ca1eda9260 63417ab6_763d_1ad1_771b_10c76ce5a8e7["mergeJSContexts()"] ec8d4bbf_da51_efdd_06cc_5efbc5901fc5 -->|calls| 63417ab6_763d_1ad1_771b_10c76ce5a8e7 style ec8d4bbf_da51_efdd_06cc_5efbc5901fc5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/core/parseJS.ts lines 7–36
export function extractScriptTags(scripts: TSXExtractedScript[]): VirtualCode[] {
const embeddedJSCodes: VirtualCode[] = [];
const moduleScripts = scripts
.filter((script) => script.type === 'module' || script.type === 'processed-module')
.map(moduleScriptToVirtualCode) satisfies VirtualCode[];
const inlineScripts = scripts
.filter(
(script) =>
// TODO: Change this at some point so that unknown scripts are not included
// We can't guarantee that they are JavaScript, so we shouldn't treat them as such, even if it might work in some cases
// Perhaps we should make it so that the user has to specify the language of the script if it's not a known type (ex: lang="js"), not sure.
script.type === 'event-attribute' || script.type === 'inline' || script.type === 'unknown',
)
.sort((a, b) => a.position.start - b.position.start);
embeddedJSCodes.push(...moduleScripts);
const mergedJSContext = mergeJSContexts(inlineScripts);
if (mergedJSContext) {
embeddedJSCodes.push(mergedJSContext);
}
const JSONScripts = scripts
.filter((script) => script.type === 'json')
.map(jsonScriptToVirtualCode) satisfies VirtualCode[];
embeddedJSCodes.push(...JSONScripts);
return embeddedJSCodes;
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does extractScriptTags() do?
extractScriptTags() is a function in the astro codebase, defined in packages/language-tools/language-server/src/core/parseJS.ts.
Where is extractScriptTags() defined?
extractScriptTags() is defined in packages/language-tools/language-server/src/core/parseJS.ts at line 7.
What does extractScriptTags() call?
extractScriptTags() calls 1 function(s): mergeJSContexts.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free