(build)
| 31 | const srcResolverPlugin: esbuild.Plugin = { |
| 32 | name: 'src-resolver', |
| 33 | setup(build) { |
| 34 | build.onResolve({ filter: /^src\// }, (args) => { |
| 35 | const basePath = resolve(ROOT, args.path) |
| 36 | |
| 37 | // Already exists as-is |
| 38 | if (existsSync(basePath)) { |
| 39 | return { path: basePath } |
| 40 | } |
| 41 | |
| 42 | // Strip .js/.jsx and try TypeScript extensions |
| 43 | const withoutExt = basePath.replace(/\.(js|jsx)$/, '') |
| 44 | for (const ext of ['.ts', '.tsx', '.js', '.jsx']) { |
| 45 | const candidate = withoutExt + ext |
| 46 | if (existsSync(candidate)) { |
| 47 | return { path: candidate } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Try as directory with index file |
| 52 | const dirPath = basePath.replace(/\.(js|jsx)$/, '') |
| 53 | for (const ext of ['.ts', '.tsx', '.js', '.jsx']) { |
| 54 | const candidate = resolve(dirPath, 'index' + ext) |
| 55 | if (existsSync(candidate)) { |
| 56 | return { path: candidate } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Let esbuild handle it (will error if truly missing) |
| 61 | return undefined |
| 62 | }) |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | const buildOptions: esbuild.BuildOptions = { |
nothing calls this directly
no test coverage detected