From 6ba2eba7b215ac5b4cb8dec60febbec37c824e63 Mon Sep 17 00:00:00 2001 From: BitterGourd <91231822+gaoachao@users.noreply.github.com> Date: Sun, 25 May 2025 17:03:56 +0800 Subject: [PATCH 1/2] feat: automatically use src/index.ts as default entry when no entry is specified --- src/features/entry.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/features/entry.ts b/src/features/entry.ts index 9f06bb574..33ef591b0 100644 --- a/src/features/entry.ts +++ b/src/features/entry.ts @@ -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' @@ -11,10 +11,15 @@ export async function resolveEntry( ): Promise> { const nameLabel = name ? `[${name}] ` : '' if (!entry || Object.keys(entry).length === 0) { - // TODO auto find entry - throw new Error( - `${nameLabel}No input files, try "tsdown " 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 " or create src/index.ts`, + ) + } } const entryMap = await toObjectEntry(entry, cwd) From 930db7038bf225db7c15b98e2b3b4af49d7319f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 27 May 2025 20:26:04 +0800 Subject: [PATCH 2/2] chore: add jsdoc --- src/options/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/options/types.ts b/src/options/types.ts index ed02a9276..2b7ce8dad 100644 --- a/src/options/types.ts +++ b/src/options/types.ts @@ -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?: