(html: string)
| 2776 | |
| 2777 | // imports of a page's module scripts, or undefined where one is inline |
| 2778 | const scriptsOf = (html: string): string | undefined => { |
| 2779 | const imports: string[] = [] |
| 2780 | for (const [tag] of html.matchAll(/<script\b[^>]*>/gi)) { |
| 2781 | if (!/\btype\s*=\s*["']?module\b/i.test(tag)) continue |
| 2782 | const src = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(tag) |
| 2783 | if (!src) return |
| 2784 | imports.push(`import ${JSON.stringify(src[1] ?? src[2] ?? src[3])}`) |
| 2785 | } |
| 2786 | return imports.join("\n") |
| 2787 | } |
| 2788 | |
| 2789 | const rollupImportsOf = ( |
| 2790 | context: RollupContext, |
no test coverage detected