(
node: DefaultTreeAdapterMap['element'],
ext: 'js',
)
| 243 | const inlineModulePaths: string[] = [] |
| 244 | |
| 245 | const addInlineModule = ( |
| 246 | node: DefaultTreeAdapterMap['element'], |
| 247 | ext: 'js', |
| 248 | ) => { |
| 249 | inlineModuleIndex++ |
| 250 | |
| 251 | const contentNode = node.childNodes[0] as DefaultTreeAdapterMap['textNode'] |
| 252 | |
| 253 | const code = contentNode.value |
| 254 | |
| 255 | let map: SourceMapInput | undefined |
| 256 | if (proxyModulePath[0] !== '\0') { |
| 257 | map = new MagicString(html) |
| 258 | .snip( |
| 259 | contentNode.sourceCodeLocation!.startOffset, |
| 260 | contentNode.sourceCodeLocation!.endOffset, |
| 261 | ) |
| 262 | .generateMap({ hires: 'boundary' }) |
| 263 | map.sources = [filename] |
| 264 | map.file = filename |
| 265 | } |
| 266 | |
| 267 | // add HTML Proxy to Map |
| 268 | addToHTMLProxyCache(config, proxyCacheUrl, inlineModuleIndex, { code, map }) |
| 269 | |
| 270 | // inline js module. convert to src="proxy" (dev only, base is never relative) |
| 271 | const modulePath = `${proxyModuleUrl}?html-proxy&index=${inlineModuleIndex}.${ext}` |
| 272 | inlineModulePaths.push(modulePath) |
| 273 | |
| 274 | s.update( |
| 275 | node.sourceCodeLocation!.startOffset, |
| 276 | node.sourceCodeLocation!.endOffset, |
| 277 | `<script type="module" src="${modulePath}"></script>`, |
| 278 | ) |
| 279 | preTransformRequest(server!, modulePath, decodedBase) |
| 280 | } |
| 281 | |
| 282 | await traverseHtml(html, filename, config.logger.warn, (node) => { |
| 283 | if (!nodeIsElement(node)) { |
no test coverage detected