Error `Invalid option in build() call: "watch"` from esbuild
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
* **tsup** 6.2.2
* using **esbuild** 0.21.5
* running on **Node** 18.20.1
### Problem
When running `tsup` or `tsup-node` with a config file (either the standard file name scheme or by setting `--config` with a file name), **esbuild** throws an error:
```
Invalid option in build() call: "watch"
// from node_modules\esbuild\lib\main.js:253:12
```
### ❌ The error is thrown:
- when using a `tsup.config.*` config file
- when using `--config some_config.ts`
- when using `--watch` _with_ a custom config (`--config` or config file)
All of these even with `watch` omitted, `watch: false` or `watch: undefined` inside the config file.
### ✔️ The error is **_not_** thrown:
- when using `--no-config`
- when using `--watch` _without_ a custom config (`--config` or config file)
### Possible cause
So it seems the parsing of the options from a config file handles the `watch` option different from the CLI `--watch` argument. Resulting in a `--watch` argument added to the esbuild command, which is not allowed anymore (see [release notes from esbuild](https://github.com/evanw/esbuild/releases/tag/v0.17.0)).
Contributor guide
Research direction
Start by reproducing the failure with tsup.config.* or --config, then compare it with --no-config and --watch without a custom config. Trace how the config-file options reach the esbuild build() call; done means custom configs no longer pass the invalid watch option while the documented watch behavior still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100