Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/features/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path'
import { glob } from 'tinyglobby'
import { lowestCommonAncestor } from '../utils/fs'
import { fsExists, lowestCommonAncestor } from '../utils/fs'
import { generateColor, logger, prettyName } from '../utils/logger'
import type { Options } from '../options'

Expand All @@ -11,10 +11,15 @@ export async function resolveEntry(
): Promise<Record<string, string>> {
const nameLabel = name ? `[${name}] ` : ''
if (!entry || Object.keys(entry).length === 0) {
// TODO auto find entry
throw new Error(
`${nameLabel}No input files, try "tsdown <your-file>" instead`,
)
const defaultEntry = path.resolve(cwd, 'src/index.ts')

if (await fsExists(defaultEntry)) {
entry = { index: defaultEntry }
} else {
throw new Error(
`${nameLabel}No input files, try "tsdown <your-file>" or create src/index.ts`,
)
}
}

const entryMap = await toObjectEntry(entry, cwd)
Expand Down
3 changes: 3 additions & 0 deletions src/options/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export interface ExportsOptions {
*/
export interface Options {
/// build options
/**
* Defaults to `'src/index.ts'` if it exists.
*/
entry?: InputOption
external?: ExternalOption
noExternal?:
Expand Down