(pattern: RegExp)
| 5189 | // Collect dependencies from this file |
| 5190 | const deps = new Set<string>(); |
| 5191 | const collectDeps = (pattern: RegExp) => { |
| 5192 | let match: RegExpExecArray | null; |
| 5193 | while ((match = pattern.exec(code)) !== null) { |
| 5194 | const spec = match[2]; |
| 5195 | if (!spec || PAT.VUE_FILE_PATTERN.test(spec) || !shouldRemapImport(spec)) { |
| 5196 | continue; |
| 5197 | } |
| 5198 | |
| 5199 | let key: string; |
| 5200 | if (spec.startsWith('/')) { |
| 5201 | key = spec; |
| 5202 | } else if (spec.startsWith('./') || spec.startsWith('../')) { |
| 5203 | key = path.posix.normalize(path.posix.join(importerDir, spec)); |
| 5204 | if (!key.startsWith('/')) key = '/' + key; |
| 5205 | } else { |
| 5206 | continue; |
| 5207 | } |
| 5208 | |
| 5209 | key = key.replace(PAT.QUERY_PATTERN, ''); |
| 5210 | deps.add(key); |
| 5211 | } |
| 5212 | }; |
| 5213 | |
| 5214 | collectDeps(PAT.IMPORT_PATTERN_1); |
| 5215 | collectDeps(PAT.IMPORT_PATTERN_2); |
no test coverage detected