Using `--entry` flag once fails with a cryptic error
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
`--entry` fails with a very confusing error message if the flag is only used once. If the flag is used multiple times, it works properly.
If the intention is that `--entry` should only be used in the case of multiple entrypoints, the error message should be made clearer. I spent a good deal of time trying to understand what `Cannot find 0` meant.
## Repro Steps
Create a test folder:
```shell
cd /tmp && mkdir test-tsup && cd test-tsup
npm init -y
npm install --save-dev typescript tsup
npx tsc --init
echo "export function hello() { console.log("world"); }" > index.ts
```
Run without `--entry` (works properly):
```shell
> npx tsup index.ts
CLI Building entry: index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.4.0
CLI Target: es2016
CJS Build start
CJS dist/index.js 1.05 KB
CJS ⚡️ Build success in 10ms
```
Run with `--entry` (fails with cryptic error message):
```shell
> npx tsup --entry index.ts
Cannot find 0: i
```
Add another entrypoint and passing the flag multiple times works:
```shell
> echo "export function hello() { console.log("world"); }" > index2.ts
> npx tsup --entry index.ts --entry index2.ts
CLI Building entry: index.ts, index2.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.4.0
CLI Target: es2016
CJS Build start
CJS dist/index.js 1.05 KB
CJS dist/index2.js 1.05 KB
CJS ⚡️ Build success in 8ms
```
Contributor guide
Research direction
Reproduce the failure with `npx tsup --entry index.ts`, then inspect the CLI handling of the `--entry` flag and compare it with the working repeated-flag case. Done means a single entry no longer produces the cryptic `Cannot find 0` error, or the command reports a clear explanation of the supported usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100