* `from './lib/adapter'` -> `from './lib/adapter.js'`, and * `from './lib/trail.svelte'` -> `from './lib/trail.svelte.js'` (the emitted * file for a `.svelte.ts` rune module). * * Driven by the filesystem rather than by the extension alone: `.svelte` is a * real file for a component and a compi
(source, fromFile)
| 93 | * looking is right for both. |
| 94 | */ |
| 95 | function resolveSpecifiers(source, fromFile) { |
| 96 | return source.replace( |
| 97 | /(\bfrom\s*|\bimport\s*\(\s*)(['"])(\.[^'"]*)\2/g, |
| 98 | (match, head, quote, spec) => { |
| 99 | if (RESOLVES.some((ext) => spec.endsWith(ext))) return match; |
| 100 | const target = resolve(dirname(fromFile), spec); |
| 101 | if (existsSync(target) && statSync(target).isFile()) return match; |
| 102 | if (!existsSync(`${target}.js`)) return match; |
| 103 | return `${head}${quote}${spec}.js${quote}`; |
| 104 | } |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | let rewritten = 0; |
| 109 | for (const path of all) { |
no test coverage detected