Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: no-dts option #458

Merged
merged 4 commits into from
Mar 3, 2024
Merged

feat: no-dts option #458

merged 4 commits into from
Mar 3, 2024

Conversation

hyoban
Copy link
Contributor

@hyoban hyoban commented Feb 18, 2024

fix #454

src/bin/index.ts Outdated Show resolved Hide resolved
src/bin/index.ts Outdated Show resolved Hide resolved
@hyoban
Copy link
Contributor Author

hyoban commented Feb 19, 2024

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.

@devjiwonchoi
Copy link
Sponsor Contributor

devjiwonchoi commented Feb 19, 2024

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.

@hyoban
Copy link
Contributor Author

hyoban commented Feb 20, 2024

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

@devjiwonchoi
Copy link
Sponsor Contributor

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.

@hyoban
Copy link
Contributor Author

hyoban commented Feb 20, 2024

Can i take a look at other cli arg parser? (If we do not want a --no-dts option)

@huozhi
Copy link
Owner

huozhi commented Mar 3, 2024

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!

@huozhi huozhi merged commit eb51315 into huozhi:main Mar 3, 2024
3 checks passed
@huozhi huozhi added this to the v5 milestone Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use typescript without generate d.ts
3 participants