| 654 | // (legacy wrapSfcWithStableDefault removed; full SFCs now delegate to /ns/asm) |
| 655 | |
| 656 | function removeNamedImports(code: string, names: string[]): string { |
| 657 | const regex = /^(\s*import\s*\{)([^}]*)(\}\s*from\s*['"][^'"]+['"];?)/gm; |
| 658 | return code.replace(regex, (_m, p1, specList, p3) => { |
| 659 | // Only strip for known globalized framework sources (Vue/Nativescript-Vue). |
| 660 | // Keep imports from all other packages (Pinia, third-party libs, app modules) intact. |
| 661 | const srcMatch = /from\s*['"]\s*([^'"\s]+)\s*['"]/i.exec(_m); |
| 662 | const src = (srcMatch?.[1] || '').toLowerCase(); |
| 663 | const isVueSource = /^(?:vue|nativescript-vue)(?:\b|\/)/i.test(src); |
| 664 | if (!isVueSource) { |
| 665 | return _m; |
| 666 | } |
| 667 | const remaining = specList |
| 668 | .split(',') |
| 669 | .map((s: string) => s.trim()) |
| 670 | .filter(Boolean) |
| 671 | .filter((entry: string) => { |
| 672 | const base = entry.split(/\s+as\s+/i)[0].trim(); |
| 673 | return !names.includes(base); |
| 674 | }); |
| 675 | |
| 676 | if (!remaining.length) return ''; |
| 677 | return `${p1} ${remaining.join(', ')} ${p3}`; |
| 678 | }); |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * Inject global bindings for given names |