MCPcopy Create free account
hub / github.com/arktypeio/arktype / esbuildEntriesOf

Function esbuildEntriesOf

ark/aot/unplugin.ts:2849–2876  ·  view source on GitHub ↗
(
	build: EsbuildBuild
)

Source from the content-addressed store, hash-verified

2847
2848// the modules esbuild starts from, stdin as a file beside what it imports
2849const 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
2879const esbuildEntryPathOf = (path: string, cwd: string) =>

Callers 1

esbuildScanOfFunction · 0.85

Calls 5

esbuildEntryPathOfFunction · 0.85
stdinEntryOfFunction · 0.85
mapMethod · 0.65
resolveMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected