/** * Extract bare import specifiers from JS code. * Matches `from 'pkg'`, `from "pkg"`, `import 'pkg'`, `import "pkg"` * where the specifier doesn't start with `.`, `/`, `http:`, or `https:`. */ export function extractBareImports(jsCode) { const imports = new Set(); const re = /(?:import\s+(?:[\s\S]*?\s+from\s+)?['"])([^'"\s][^'"]*?)(?=['"])/g; let match; while ((match = re.exec(jsCode)) !== null) { const spec = match[1]; // Skip relative, absolute, and URL imports if (spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('http:') || spec.startsWith('https:')) { continue; } // Skip svelte internal imports (already rewritten by the compiler) if (spec.startsWith('svelte')) continue; imports.add(spec); } return Array.from(imports); } /** * Build an HTML