Why doesn't the flag --env.NODE_ENV and the option --onSuccess take effect?
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
I would like the generated results to be automatically executed following the successful completion of the compilation process, and for that compilation to utilize the configuration corresponding to the specific environment.
```json
"scripts": {
"dev": "tsup --watch --env.NODE_ENV development --onSuccess 'node dist/app.js'"
}
```
```ts
// tsup.config.ts
import { defineConfig } from "tsup";
const isDev = process.env.NODE_ENV === "development";
console.log("isDev", process.env.NODE_ENV);
export default defineConfig({
target: "es2020",
entry: ["lib/app.ts"],
outDir: "dist",
format: ["cjs", "esm"],
dts: !isDev,
minify: !isDev,
clean: true,
sourcemap: isDev
});
```
result:

Why doesn't the flag `--env.NODE_ENV` and the option `--onSuccess` take effect?
What should I do?
Contributor guide
Research direction
Reproduce the package script using tsup.config.ts and the shown --watch, --env.NODE_ENV, and --onSuccess options. Start by tracing how the CLI loads tsup.config.ts and handles those options; done means the environment-specific settings are applied and node dist/app.js runs after a successful compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100