| 31 | const TYPE_SCRIPT_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts"]) |
| 32 | |
| 33 | const toLocalDistPath = (pathService: Path.Path, packageDir: string, resolvedId: string): string => { |
| 34 | const srcDir = pathService.join(packageDir, "src") |
| 35 | const relative = pathService.relative(srcDir, resolvedId) |
| 36 | if (relative === "" || relative.startsWith("..") || pathService.isAbsolute(relative)) { |
| 37 | return resolvedId |
| 38 | } |
| 39 | const extension = pathService.extname(relative) |
| 40 | if (!TYPE_SCRIPT_EXTENSIONS.has(extension)) { |
| 41 | return resolvedId |
| 42 | } |
| 43 | return pathService.join(packageDir, "dist", relative.slice(0, -extension.length) + ".js") |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Options for configuring Rollup plugins. |