MCPcopy
hub / github.com/rolldown/tsdown / resolveEntry

Function resolveEntry

src/features/entry.ts:11–41  ·  view source on GitHub ↗
(
  logger: Logger,
  entry: UserConfig['entry'],
  cwd: string,
  color: Ansis,
  nameLabel?: string,
  root?: string,
)

Source from the content-addressed store, hash-verified

9import type { Ansis } from 'ansis'
10
11export async function resolveEntry(
12 logger: Logger,
13 entry: UserConfig['entry'],
14 cwd: string,
15 color: Ansis,
16 nameLabel?: string,
17 root?: string,
18): Promise<[entry: Record<string, string>, root: string]> {
19 if (!entry || Object.keys(entry).length === 0) {
20 const defaultEntry = path.resolve(cwd, 'src/index.ts')
21
22 if (await fsExists(defaultEntry)) {
23 entry = { index: defaultEntry }
24 } else {
25 throw new Error(
26 `${nameLabel} No input files, try "tsdown <your-file>" or create src/index.ts`,
27 )
28 }
29 }
30
31 const [entryMap, computedRoot] = await toObjectEntry(entry, cwd, root)
32 const entries = Object.values(entryMap)
33 if (entries.length === 0) {
34 throw new Error(`${nameLabel} Cannot find entry: ${JSON.stringify(entry)}`)
35 }
36 logger.info(
37 nameLabel,
38 `entry: ${color(entries.map((entry) => (path.isAbsolute(entry) ? path.relative(cwd, entry) : entry)).join(', '))}`,
39 )
40 return [entryMap, computedRoot]
41}
42
43export function toObjectEntry(
44 entry: TsdownInputOption,

Callers 1

resolveUserConfigFunction · 0.90

Calls 2

fsExistsFunction · 0.90
toObjectEntryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…