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: support only output dts #253

Merged
merged 3 commits into from
Aug 4, 2023
Merged

feat: support only output dts #253

merged 3 commits into from
Aug 4, 2023

Conversation

biggerstar
Copy link
Contributor

过去输出dts同时会输出其他js产物
现在支持仅输出dts文件

@qmhc
Copy link
Owner

qmhc commented Jul 27, 2023

是什么场景会使得:仅使用 vite 打包 dts,而用其他工具打包 js 代码?

@biggerstar
Copy link
Contributor Author

biggerstar commented Jul 27, 2023

这是一个需求vue-core
并非你说的 仅使用 vite 打包 dts,而用其他工具打包 js 代码
在某些情况下,可能在测试dts的时候我们只需要打包dts而不需要其他js产物
而在我最近开发的一个工具中也有这种需求vite-run
另外像一些大型仓库一般都有dts和源码分开打包的需求vue-core-rollup.dts.config.js
他们可以只在需要打包dts的自定义脚本中引入vite-plugin-dts就行,如果输出多余产物可能会污染原本打包内容

@biggerstar
Copy link
Contributor Author

上面说的仅使用 vite 打包 dts,而用其他工具打包 js 代码我还没回答清楚
这是回答: 打包需求可以都使用vite, 只是可能有分开打包的需求

@@ -28,6 +28,7 @@ export default defineConfig({
staticImport: true,
// insertTypesEntry: true,
rollupTypes: true
// onlyDts:tru
Copy link
Owner

Choose a reason for hiding this comment

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

请删除错误的注释内容

src/plugin.ts Outdated
@@ -680,6 +681,13 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin {
logger.info(
green(`${logPrefix} Declaration files built in ${timeRecord + Date.now() - startTime}ms.\n`)
)
},
generateBundle(_: any, bundle: Record<any, any>) {
Copy link
Owner

Choose a reason for hiding this comment

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

请直接让 ts 自行推导类型,无需显式定义类型

src/types.ts Outdated
/**
* Whether to output only dts
*/
onlyDts?: boolean,
Copy link
Owner

Choose a reason for hiding this comment

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

请更名为 declarationOnly,并配上更详细的描述,特别要描述该选项会删除所有 vite 打包的原始产物,同时应添加默认值说明。

除此之外,还需要在两个 README 的选项文档中添加相应的内容。

@qmhc qmhc merged commit a23d063 into qmhc:main Aug 4, 2023
4 checks passed
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.

2 participants