| 27 | } |
| 28 | |
| 29 | function pickSourceIndex(map, relPath) { |
| 30 | if (!Array.isArray(map.sources) || !Array.isArray(map.sourcesContent)) { |
| 31 | return -1 |
| 32 | } |
| 33 | |
| 34 | const relBasename = path.posix.basename(relPath) |
| 35 | |
| 36 | let index = map.sources.findIndex(source => { |
| 37 | if (typeof source !== 'string') return false |
| 38 | return source.replaceAll('\\', '/').endsWith(relPath) |
| 39 | }) |
| 40 | if (index >= 0) return index |
| 41 | |
| 42 | index = map.sources.findIndex(source => { |
| 43 | if (typeof source !== 'string') return false |
| 44 | return path.posix.basename(source.replaceAll('\\', '/')) === relBasename |
| 45 | }) |
| 46 | if (index >= 0) return index |
| 47 | |
| 48 | return map.sources.length === 1 ? 0 : -1 |
| 49 | } |
| 50 | |
| 51 | function applyCompatRewrites(sourceText) { |
| 52 | return sourceText |