(globsResolved: string[])
| 690 | } |
| 691 | |
| 692 | export function getCommonBase(globsResolved: string[]): null | string { |
| 693 | const bases = globsResolved |
| 694 | .filter((g) => g[0] !== '!') |
| 695 | .map((glob) => { |
| 696 | let { base } = picomatch.scan(glob) |
| 697 | // `scan('a/foo.js')` returns `base: 'a/foo.js'` |
| 698 | if (posix.basename(base).includes('.')) base = posix.dirname(base) |
| 699 | |
| 700 | return base |
| 701 | }) |
| 702 | |
| 703 | if (!bases.length) return null |
| 704 | |
| 705 | let commonAncestor = '' |
| 706 | const dirS = bases[0].split('/') |
| 707 | for (let i = 0; i < dirS.length; i++) { |
| 708 | const candidate = dirS.slice(0, i + 1).join('/') |
| 709 | if ( |
| 710 | bases.every( |
| 711 | (base) => base === candidate || base.startsWith(`${candidate}/`), |
| 712 | ) |
| 713 | ) |
| 714 | commonAncestor = candidate |
| 715 | else break |
| 716 | } |
| 717 | if (!commonAncestor) commonAncestor = '/' |
| 718 | |
| 719 | return commonAncestor |
| 720 | } |
| 721 | |
| 722 | export function isVirtualModule(id: string): boolean { |
| 723 | // https://vite.dev/guide/api-plugin.html#virtual-modules-convention |
no outgoing calls
no test coverage detected