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: add defineConfig function in dts-cli/config #142

Merged
merged 1 commit into from
Apr 9, 2022
Merged

feat: add defineConfig function in dts-cli/config #142

merged 1 commit into from
Apr 9, 2022

Conversation

ToppleTheNun
Copy link

add defineConfig function that can be used from dts.config.ts or
dts.config.js in order to provide IntelliSense for configuration
options.

move configuration loading logic into getDtsConfig and
getNormalizedDtsConfig in src/createBuildConfigs.ts.
getDtsConfig loads the appropriate dts.config.* file.
getNormalizedDtsConfig normalizes the loaded configuration by
providing default values for the otherwise nullable values in DtsConfig.

this setup would allow for easy use of babel-node if so desired
to allow the use of import statements in dts.config.js.

@aladdin-add
Copy link

aladdin-add commented Apr 6, 2022

the easiest way I can see is to just export:

export function defineConfig(opts: DtsOptions){
  return opts;
}

and the defineConfig should be exported from "dts-cli"(instead of "dts-cli/config"), to be the same as DtsOptions, thoughts?

@ToppleTheNun
Copy link
Author

It should be available to be used as both

import { defineConfig } from "dts-cli/config";

and

import { defineConfig } from "dts-cli";

with the current implementation.

@aladdin-add
Copy link

but what's the benefit? Generally, it's no good to have multiple ways to do one thing.

@aladdin-add aladdin-add self-requested a review April 6, 2022 06:45
@ToppleTheNun
Copy link
Author

I originally went with both due to a desire to align with how vite/vitest do it, as well as not break users who are used to using just the import { DtsOptions, RollupOptions } from "dts-cli".

I'll change it to just the one import from the root.

add `defineConfig` function that can be used from dts.config.ts or
dts.config.js in order to provide IntelliSense for configuration
options.

move configuration loading logic into `getDtsConfig` and
`getNormalizedDtsConfig` in src/createBuildConfigs.ts.
`getDtsConfig` loads the appropriate dts.config.* file.
`getNormalizedDtsConfig` normalizes the loaded configuration by
providing default values for the otherwise nullable values in DtsConfig.

this setup would allow for easy use of babel-node if so desired
to allow the use of `import` statements in dts.config.js.
Copy link

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@aladdin-add aladdin-add merged commit 0b3b2dd into weiran-zsd:main Apr 9, 2022
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.

None yet

2 participants