MCPcopy
hub / github.com/vitejs/vite / getScriptInfo

Function getScriptInfo

packages/vite/src/node/plugins/html.ts:225–253  ·  view source on GitHub ↗
(node: DefaultTreeAdapterMap['element'])

Source from the content-addressed store, hash-verified

223}
224
225export function getScriptInfo(node: DefaultTreeAdapterMap['element']): {
226 src: Token.Attribute | undefined
227 srcSourceCodeLocation: Token.Location | undefined
228 isModule: boolean
229 isAsync: boolean
230 isIgnored: boolean
231} {
232 let src: Token.Attribute | undefined
233 let srcSourceCodeLocation: Token.Location | undefined
234 let isModule = false
235 let isAsync = false
236 let isIgnored = false
237 for (const p of node.attrs) {
238 if (p.prefix !== undefined) continue
239 if (p.name === 'src') {
240 if (!src) {
241 src = p
242 srcSourceCodeLocation = node.sourceCodeLocation?.attrs!.src
243 }
244 } else if (p.name === 'type' && p.value === 'module') {
245 isModule = true
246 } else if (p.name === 'async') {
247 isAsync = true
248 } else if (p.name === 'vite-ignore') {
249 isIgnored = true
250 }
251 }
252 return { src, srcSourceCodeLocation, isModule, isAsync, isIgnored }
253}
254
255const attrValueStartRE = /=\s*(.)/
256

Callers 2

devHtmlHookFunction · 0.90
handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected