File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11import path from 'node:path'
22import { glob } from 'tinyglobby'
3- import { lowestCommonAncestor } from '../utils/fs'
3+ import { fsExists , lowestCommonAncestor } from '../utils/fs'
44import { generateColor , logger , prettyName } from '../utils/logger'
55import type { Options } from '../options'
66
@@ -11,10 +11,15 @@ export async function resolveEntry(
1111) : Promise < Record < string , string > > {
1212 const nameLabel = name ? `[${ name } ] ` : ''
1313 if ( ! entry || Object . keys ( entry ) . length === 0 ) {
14- // TODO auto find entry
15- throw new Error (
16- `${ nameLabel } No input files, try "tsdown <your-file>" instead` ,
17- )
14+ const defaultEntry = path . resolve ( cwd , 'src/index.ts' )
15+
16+ if ( await fsExists ( defaultEntry ) ) {
17+ entry = { index : defaultEntry }
18+ } else {
19+ throw new Error (
20+ `${ nameLabel } No input files, try "tsdown <your-file>" or create src/index.ts` ,
21+ )
22+ }
1823 }
1924
2025 const entryMap = await toObjectEntry ( entry , cwd )
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ export interface ExportsOptions {
9191 */
9292export interface Options {
9393 /// build options
94+ /**
95+ * Defaults to `'src/index.ts'` if it exists.
96+ */
9497 entry ?: InputOption
9598 external ?: ExternalOption
9699 noExternal ?:
You can’t perform that action at this time.
0 commit comments