feat: no-dts option
fix #454
Don't know how to use arg to distinguish between undefined and false. So i keep no-dts option in cli, but merge it with dts.
Since for TS projects, currently bunchee is always generating d.ts regardless of CLI args like --dts false.
We could check if dts is nullish and set to true if hasTsConfig exists, and make sure to not run the typesJobs if dts is falsy.
// better to use const
dts ??= Boolean(hasTsConfig)
//...
const typesJobs = dts
? (await buildEntryConfig(options, buildContext, true)).map(
(rollupConfig) => bundleOrWatch(rollupConfig),
)
: []
In this case we can decide not to generate d.ts on TS projects by --dts false while preserving other behaviors.
Note that Boolean and [Boolean] have special treatment - an option argument is not consumed or passed, but instead true is returned. These options are called "flags".
It seems we can not let arg to receive --dts false
I see.. I was expecting the behavior of --declaration in tsc.
IMO expanding the --no-<arg> family might not be the best option, but seems reasonable at the moment.
Can i take a look at other cli arg parser? (If we do not want a --no-dts option)
We already have the --no-dts option value, so we can check it first. I pushed a refactor commit aligning with how we handled others like --no-external.
It looks good now! Thank you both for the PR and the discussion above!