Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
biggerstar committed Jul 27, 2023
2 parents 325eec5 + 4738ab2 commit feb5ba2
Show file tree
Hide file tree
Showing 20 changed files with 1,609 additions and 165 deletions.
1,232 changes: 1,232 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -280,20 +280,21 @@ export interface PluginOptions {
*
* This allows you to transform the path or content
*
* The file will be skipped when the return value `false`
* The file will be skipped when the return value `false` or `Promise<false>`
*
* @default () => {}
*/
beforeWriteFile?: (
filePath: string,
content: string
) =>
| void
| false
| {
filePath?: string,
content?: string
},
) => MaybePromise<
| void
| false
| {
filePath?: string,
content?: string
}
>,

/**
* Hook called after all declaration files are written
Expand Down
17 changes: 9 additions & 8 deletions README.zh-CN.md
Expand Up @@ -280,20 +280,21 @@ export interface PluginOptions {
*
* 可以在钩子里转换文件路径和文件内容
*
* 当返回 `false` 时会跳过该文件
* 当返回 `false` 或 `Promise<false>` 时会跳过该文件
*
* @default () => {}
*/
beforeWriteFile?: (
filePath: string,
content: string
) =>
| void
| false
| {
filePath?: string,
content?: string
},
) => MaybePromise<
| void
| false
| {
filePath?: string,
content?: string
}
>,

/**
* 在所有类型文件被写入后调用的钩子
Expand Down
1 change: 1 addition & 0 deletions examples/react/package.json
Expand Up @@ -16,6 +16,7 @@
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.0.1",
"tslib": "^2.5.3",
"typescript": "5.0.4",
"vite": "^4.3.9"
}
}
1 change: 1 addition & 0 deletions examples/svelte/package.json
Expand Up @@ -13,6 +13,7 @@
"svelte": "^3.58.0",
"svelte-check": "^3.3.1",
"tslib": "^2.5.3",
"typescript": "5.0.4",
"vite": "^4.3.9"
}
}
2 changes: 2 additions & 0 deletions examples/ts/package.json
Expand Up @@ -7,8 +7,10 @@
"scripts": {
"build": "DEBUG=\"vite-plugin-dts:bundle\" vite build"
},
"types": "dist/ts-test.d.ts",
"devDependencies": {
"tslib": "^2.5.3",
"typescript": "5.0.4",
"vite": "^4.3.9"
}
}
3 changes: 2 additions & 1 deletion examples/ts/src/index.ts
Expand Up @@ -8,13 +8,14 @@ export interface Test extends TestBase {

export { testFn } from './comment'
export { Decorator } from './decorator'
export { addOne, add } from '@/js-test.js'
export { addOne, add, jsdoc } from '@/js-test.js'
export { ESClass } from './es-class'
export { manualDts } from './manual-dts'

export { ParametersTest, test, method } from './test'

export { data }
export default data

export type { User } from './types'
export type { AliasType } from '@alias/type'
9 changes: 9 additions & 0 deletions examples/ts/src/js-test.js
Expand Up @@ -5,3 +5,12 @@ export const addOne = x => parseFloat(x) + 1
export function add(...args) {
return args.reduce((total, num) => total + num, 0)
}

/**
* @param {number} one
* @param {number} two
* @returns {string}
*/
export function jsdoc(one, two) {
return `${one + two}`
}
4 changes: 2 additions & 2 deletions examples/ts/vite.config.ts
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
build: {
lib: {
entry: [resolve(__dirname, 'src/index.ts'), resolve(__dirname, 'src/main.ts')],
name: 'Test',
name: 'ts-test',
formats: ['es']
}
},
Expand All @@ -28,7 +28,7 @@ export default defineConfig({
staticImport: true,
// insertTypesEntry: true,
rollupTypes: true
// onlyDts:true
// onlyDts:tru
})
]
})
Expand Down
10 changes: 5 additions & 5 deletions examples/vue/components/TypeProps.vue
@@ -1,5 +1,9 @@
<template>
<div>{{ color }}</div>
</template>

<script setup lang="ts">
type Props = {
export type Props = {
color: 'blue' | 'red' | 'purple',
array?: { foo: number }[]
}
Expand All @@ -17,7 +21,3 @@ interface Events {
defineEmits<Events>()
</script>

<template>
<div>{{ color }}</div>
</template>
1 change: 1 addition & 0 deletions examples/vue/package.json
Expand Up @@ -14,6 +14,7 @@
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"tslib": "^2.5.3",
"typescript": "5.0.4",
"vite": "^4.3.9"
}
}
13 changes: 10 additions & 3 deletions examples/vue/vite.config.ts
Expand Up @@ -30,12 +30,19 @@ export default defineConfig({
plugins: [
dts({
copyDtsFiles: true,
outDir: ['dist', 'types'],
outDir: [
'dist',
'types'
// 'types/inner'
],
// include: ['src/index.ts'],
exclude: ['src/ignore'],
staticImport: true,
rollupTypes: true,
insertTypesEntry: true
// rollupTypes: true,
insertTypesEntry: true,
compilerOptions: {
declarationMap: true
}
}),
vue(),
vueJsx()
Expand Down
13 changes: 7 additions & 6 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-dts",
"version": "3.2.0",
"version": "3.3.1",
"type": "module",
"license": "MIT",
"author": "qmhc",
Expand Down Expand Up @@ -55,7 +55,6 @@
"dependencies": {
"@microsoft/api-extractor": "^7.36.0",
"@rollup/pluginutils": "^5.0.2",
"@rushstack/node-core-library": "^3.59.4",
"@vue/language-core": "^1.8.1",
"debug": "^4.3.4",
"kolorist": "^1.8.0",
Expand Down Expand Up @@ -96,10 +95,12 @@
"vitest": "^0.32.2"
},
"peerDependencies": {
"typescript": "*"
},
"optionalDependencies": {
"rollup": "*",
"typescript": "*",
"vite": "*"
},
"peerDependenciesMeta": {
"vite": {
"optional": true
}
}
}

0 comments on commit feb5ba2

Please sign in to comment.