( build: EsbuildBuild )
| 2847 | |
| 2848 | // the modules esbuild starts from, stdin as a file beside what it imports |
| 2849 | const esbuildEntriesOf = async ( |
| 2850 | build: EsbuildBuild |
| 2851 | ): Promise<ScanEntry[] | string> => { |
| 2852 | const { entryPoints, absWorkingDir = process.cwd() } = build.initialOptions |
| 2853 | const paths = |
| 2854 | Array.isArray(entryPoints) ? |
| 2855 | entryPoints.map(entry => (typeof entry === "string" ? entry : entry.in)) |
| 2856 | : entryPoints && typeof entryPoints === "object" ? |
| 2857 | Object.values(entryPoints as Record<string, string>) |
| 2858 | : [] |
| 2859 | const entries: ScanEntry[] = [] |
| 2860 | for (const path of paths) { |
| 2861 | const result = await build.resolve( |
| 2862 | esbuildEntryPathOf(path, absWorkingDir), |
| 2863 | { |
| 2864 | kind: "entry-point", |
| 2865 | resolveDir: absWorkingDir, |
| 2866 | pluginData: esbuildResolution |
| 2867 | } |
| 2868 | ) |
| 2869 | if (result.errors.length || result.namespace !== "file") |
| 2870 | return `the entry "${path}" doesn't resolve to a file` |
| 2871 | entries.push({ id: result.path }) |
| 2872 | } |
| 2873 | const entry = stdinEntryOf(build.initialOptions) |
| 2874 | if (entry) entries.push(entry) |
| 2875 | return entries |
| 2876 | } |
| 2877 | |
| 2878 | // esbuild reads an entry naming a file in cwd as a path, though it would resolve it as a package |
| 2879 | const esbuildEntryPathOf = (path: string, cwd: string) => |
no test coverage detected