(filePath: string, source: string)
| 43 | } |
| 44 | |
| 45 | function rewriteSpecifiers(filePath: string, source: string): string { |
| 46 | const patterns = [ |
| 47 | /(from\s+["'])(\.\.?\/[^"']+)(["'])/g, |
| 48 | /(import\s+["'])(\.\.?\/[^"']+)(["'])/g, |
| 49 | /(import\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, |
| 50 | ]; |
| 51 | |
| 52 | return patterns.reduce( |
| 53 | (nextSource, pattern) => |
| 54 | nextSource.replace(pattern, (_match, prefix: string, specifier: string, suffix: string) => { |
| 55 | return `${prefix}${resolveRuntimeSpecifier(filePath, specifier)}${suffix}`; |
| 56 | }), |
| 57 | source, |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | let changed = 0; |
| 62 | for (const filePath of listJavaScriptFiles(distDir)) { |
no test coverage detected