init
This commit is contained in:
21
node_modules/vite-plugin-dts/LICENSE
generated
vendored
Normal file
21
node_modules/vite-plugin-dts/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021-present qmhc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
393
node_modules/vite-plugin-dts/README.md
generated
vendored
Normal file
393
node_modules/vite-plugin-dts/README.md
generated
vendored
Normal file
@ -0,0 +1,393 @@
|
||||
<h1 align="center">vite-plugin-dts</h1>
|
||||
|
||||
<p align="center">
|
||||
A Vite plugin that generates declaration files (<code>*.d.ts</code>) from <code>.ts(x)</code> or <code>.vue</code> source files when using Vite in <a href="https://vitejs.dev/guide/build.html#library-mode">library mode</a>.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/vite-plugin-dts">
|
||||
<img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
|
||||
</a>
|
||||
<a href="https://github.com/qmhc/vite-plugin-dts/blob/main/LICENSE">
|
||||
<img src="https://img.shields.io/npm/l/vite-plugin-dts" alt="license" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
**English** | [中文](./README.zh-CN.md)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
pnpm i vite-plugin-dts -D
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
In `vite.config.ts`:
|
||||
|
||||
```ts
|
||||
import { resolve } from 'path'
|
||||
import { defineConfig } from 'vite'
|
||||
import dts from 'vite-plugin-dts'
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/index.ts'),
|
||||
name: 'MyLib',
|
||||
formats: ['es'],
|
||||
fileName: 'my-lib'
|
||||
}
|
||||
},
|
||||
plugins: [dts()]
|
||||
})
|
||||
```
|
||||
|
||||
By default, the generated declaration files are following the source structure.
|
||||
|
||||
If you want to merge all declarations into one file, just specify `rollupTypes: true`:
|
||||
|
||||
```ts
|
||||
{
|
||||
plugins: [dts({ rollupTypes: true })]
|
||||
}
|
||||
```
|
||||
|
||||
Starting with `3.0.0`, you can use this plugin with Rollup.
|
||||
|
||||
## FAQ
|
||||
|
||||
Here are some FAQ's and solutions.
|
||||
|
||||
### Type errors that are unable to infer types from packages in `node_modules`
|
||||
|
||||
This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/issues/42873) where TypeScript infers types from packages located in `node_modules` through soft links (pnpm). A workaround is to add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"third-lib": ["node_modules/third-lib"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `Internal Error` occurs when using `rollupTypes: true`
|
||||
|
||||
Refer to this [issue](https://github.com/microsoft/rushstack/issues/3875), it's due to a limitation of `@microsoft/api-extractor` or TypeScript resolver.
|
||||
|
||||
The main reason is that `baseUrl` is specified in `tsconfig.json` and non-standard paths are used directly when imported.
|
||||
|
||||
For example: `baseUrl: 'src'` is specified and importing from `<root>/src/components/index.ts` in `<root>/src/index.ts`, and `import 'components'` is used instead of `import './components'`.
|
||||
|
||||
Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
|
||||
|
||||
<details>
|
||||
<summary>Legacy</summary>
|
||||
|
||||
### Missing some declaration files after build (before `1.7.0`)
|
||||
|
||||
By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
|
||||
|
||||
If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
|
||||
|
||||
### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
|
||||
|
||||
This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
|
||||
|
||||
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
|
||||
|
||||
</details>
|
||||
|
||||
## Options
|
||||
|
||||
```ts
|
||||
import type ts from 'typescript'
|
||||
import type { IExtractorConfigPrepareOptions, IExtractorInvokeOptions } from '@microsoft/api-extractor'
|
||||
import type { LogLevel } from 'vite'
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>
|
||||
|
||||
export type RollupConfig = Omit<
|
||||
IExtractorConfigPrepareOptions['configObject'],
|
||||
| 'projectFolder'
|
||||
| 'mainEntryPointFilePath'
|
||||
| 'compiler'
|
||||
| 'dtsRollup'
|
||||
>
|
||||
|
||||
export interface Resolver {
|
||||
/**
|
||||
* The name of the resolver
|
||||
*
|
||||
* The later resolver with the same name will overwrite the earlier
|
||||
*/
|
||||
name: string,
|
||||
/**
|
||||
* Determine whether the resolver supports the file
|
||||
*/
|
||||
supports: (id: string) => void | boolean,
|
||||
/**
|
||||
* Transform source to declaration files
|
||||
*
|
||||
* Note that the path of the returns should base on `outDir`, or relative path to `root`
|
||||
*/
|
||||
transform: (payload: {
|
||||
id: string,
|
||||
code: string,
|
||||
root: string,
|
||||
outDir: string,
|
||||
host: ts.CompilerHost,
|
||||
program: ts.Program,
|
||||
service: ts.LanguageService
|
||||
}) => MaybePromise<{ path: string, content: string }[]>
|
||||
}
|
||||
|
||||
export interface PluginOptions {
|
||||
/**
|
||||
* Specify root directory
|
||||
*
|
||||
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
||||
*/
|
||||
root?: string,
|
||||
|
||||
/**
|
||||
* Output directory for declaration files
|
||||
*
|
||||
* Can be an array to output to multiple directories
|
||||
*
|
||||
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
||||
*/
|
||||
outDir?: string | string[],
|
||||
|
||||
/**
|
||||
* Override root path of entry files (useful in monorepos)
|
||||
*
|
||||
* The output path of each file will be calculated based on the value provided
|
||||
*
|
||||
* The default is the smallest public path for all source files
|
||||
*/
|
||||
entryRoot?: string,
|
||||
|
||||
/**
|
||||
* Restrict declaration files output to `outDir`
|
||||
*
|
||||
* If true, generated declaration files outside `outDir` will be ignored
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
strictOutput?: boolean,
|
||||
|
||||
/**
|
||||
* Override compilerOptions
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
compilerOptions?: ts.CompilerOptions | null,
|
||||
|
||||
/**
|
||||
* Specify tsconfig.json path
|
||||
*
|
||||
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
||||
*
|
||||
* If not specified, plugin will find config file from root
|
||||
*/
|
||||
tsconfigPath?: string,
|
||||
|
||||
/**
|
||||
* Specify custom resolvers
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
resolvers?: Resolver[],
|
||||
|
||||
/**
|
||||
* Parsing `paths` of tsconfig.json to aliases
|
||||
*
|
||||
* Note that these aliases only use for declaration files
|
||||
*
|
||||
* @default true
|
||||
* @remarks Only use first replacement of each path
|
||||
*/
|
||||
pathsToAliases?: boolean,
|
||||
|
||||
/**
|
||||
* Set which paths should be excluded when transforming aliases
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
aliasesExclude?: (string | RegExp)[],
|
||||
|
||||
/**
|
||||
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cleanVueFileName?: boolean,
|
||||
|
||||
/**
|
||||
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
staticImport?: boolean,
|
||||
|
||||
/**
|
||||
* Override `include` glob (relative to root)
|
||||
*
|
||||
* Defaults to `include` property of tsconfig.json (relative to tsconfig.json located)
|
||||
*/
|
||||
include?: string | string[],
|
||||
|
||||
/**
|
||||
* Override `exclude` glob
|
||||
*
|
||||
* Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
|
||||
*/
|
||||
exclude?: string | string[],
|
||||
|
||||
/**
|
||||
* Whether to remove `import 'xxx'`
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
clearPureImport?: boolean,
|
||||
|
||||
/**
|
||||
* Whether to generate types entry file(s)
|
||||
*
|
||||
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
insertTypesEntry?: boolean,
|
||||
|
||||
/**
|
||||
* Rollup type declaration files after emitting them
|
||||
*
|
||||
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
rollupTypes?: boolean,
|
||||
|
||||
/**
|
||||
* Bundled packages for `@microsoft/api-extractor`
|
||||
*
|
||||
* @default []
|
||||
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
||||
*/
|
||||
bundledPackages?: string[],
|
||||
|
||||
/**
|
||||
* Override the config of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
||||
*/
|
||||
rollupConfig?: RollupConfig,
|
||||
|
||||
/**
|
||||
* Override the invoke options of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
|
||||
*/
|
||||
rollupOptions?: IExtractorInvokeOptions,
|
||||
|
||||
/**
|
||||
* Whether to copy .d.ts source files to `outDir`
|
||||
*
|
||||
* @default false
|
||||
* @remarks Before 2.0, the default was `true`
|
||||
*/
|
||||
copyDtsFiles?: boolean,
|
||||
|
||||
/**
|
||||
* Whether to emit declaration files only
|
||||
*
|
||||
* When `true`, all the original outputs of vite (rollup) will be force removed
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
declarationOnly?: boolean,
|
||||
|
||||
/**
|
||||
* Logging level for this plugin
|
||||
*
|
||||
* Defaults to the 'logLevel' property of your Vite config
|
||||
*/
|
||||
logLevel?: LogLevel,
|
||||
|
||||
/**
|
||||
* Hook called after diagnostic is emitted
|
||||
*
|
||||
* According to the `diagnostics.length`, you can judge whether there is any type error
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
|
||||
|
||||
/**
|
||||
* Hook called prior to writing each declaration file
|
||||
*
|
||||
* This allows you to transform the path or content
|
||||
*
|
||||
* The file will be skipped when the return value `false` or `Promise<false>`
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
beforeWriteFile?: (
|
||||
filePath: string,
|
||||
content: string
|
||||
) => MaybePromise<
|
||||
| void
|
||||
| false
|
||||
| {
|
||||
filePath?: string,
|
||||
content?: string
|
||||
}
|
||||
>,
|
||||
|
||||
/**
|
||||
* Hook called after all declaration files are written
|
||||
*
|
||||
* It will be received a map (path -> content) that records those emitted files
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterBuild?: () => MaybePromise<void>
|
||||
}
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
Thanks for all the contributions!
|
||||
|
||||
<a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
|
||||
</a>
|
||||
|
||||
## Example
|
||||
|
||||
Clone and run the following script:
|
||||
|
||||
```sh
|
||||
pnpm run test:ts
|
||||
```
|
||||
|
||||
Then check `examples/ts/types`.
|
||||
|
||||
Also Vue and React cases under `examples`.
|
||||
|
||||
A real project using this plugin: [Vexip UI](https://github.com/vexip-ui/vexip-ui).
|
||||
|
||||
## License
|
||||
|
||||
MIT License.
|
393
node_modules/vite-plugin-dts/README.zh-CN.md
generated
vendored
Normal file
393
node_modules/vite-plugin-dts/README.zh-CN.md
generated
vendored
Normal file
@ -0,0 +1,393 @@
|
||||
<h1 align="center">vite-plugin-dts</h1>
|
||||
|
||||
<p align="center">
|
||||
一款用于在 <a href="https://cn.vitejs.dev/guide/build.html#library-mode">库模式</a> 中从 <code>.ts(x)</code> 或 <code>.vue</code> 源文件生成类型文件(<code>*.d.ts</code>)的 Vite 插件。
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/vite-plugin-dts">
|
||||
<img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
|
||||
</a>
|
||||
<a href="https://github.com/qmhc/vite-plugin-dts/blob/main/LICENSE">
|
||||
<img src="https://img.shields.io/npm/l/vite-plugin-dts" alt="license" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
**中文** | [English](./README.md)
|
||||
|
||||
## 安装
|
||||
|
||||
```sh
|
||||
pnpm i vite-plugin-dts -D
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||
在 `vite.config.ts`:
|
||||
|
||||
```ts
|
||||
import { resolve } from 'path'
|
||||
import { defineConfig } from 'vite'
|
||||
import dts from 'vite-plugin-dts'
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/index.ts'),
|
||||
name: 'MyLib',
|
||||
formats: ['es'],
|
||||
fileName: 'my-lib'
|
||||
}
|
||||
},
|
||||
plugins: [dts()]
|
||||
})
|
||||
```
|
||||
|
||||
默认情况,生成的类型文件会跟随源文件的结构。
|
||||
|
||||
如果你希望将所有的类型合并到一个文件中,只需指定 `rollupTypes: true`:
|
||||
|
||||
```ts
|
||||
{
|
||||
plugins: [dts({ rollupTypes: true })]
|
||||
}
|
||||
```
|
||||
|
||||
从 `3.0.0` 开始,你可以在 Rollup 中使用该插件。
|
||||
|
||||
## 常见问题
|
||||
|
||||
此处将收录一些常见的问题并提供一些解决方案。
|
||||
|
||||
### 打包时出现了无法从 `node_modules` 的包中推断类型的错误
|
||||
|
||||
这是 TypeScript 通过软链接 (pnpm) 读取 `node_modules` 中过的类型时会出现的一个已知的问题,可以参考这个 [issue](https://github.com/microsoft/TypeScript/issues/42873),目前已有的一个解决方案,在你的 `tsconfig.json` 中添加 `baseUrl` 以及在 `paths` 添加这些包的路径:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"third-lib": ["node_modules/third-lib"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 在 `rollupTypes: true` 时出现 `Internal Error`
|
||||
|
||||
参考这个 [issue](https://github.com/microsoft/rushstack/issues/3875),这是由于 `@microsoft/api-extractor` 或者是 TypeScript 解析器的一些限制导致的。
|
||||
|
||||
主要原因在于 `tsconfig.json` 中指定了 `baseUrl` 并且在引入时直接使用非标准路径。
|
||||
|
||||
例如:指定了 `baseUrl: 'src'` 并且在 `<root>/src/index.ts` 中引入 `<root>/src/components/index.ts` 时使用了 `import 'components'` 而不是 `import './components'`。
|
||||
|
||||
目前想要正常打包,需要规避上述情况,或使用别名代替(配合 `paths` 属性)。
|
||||
|
||||
<details>
|
||||
<summary>过时的</summary>
|
||||
|
||||
### 打包后出现类型文件缺失 (`1.7.0` 之前)
|
||||
|
||||
默认情况下 `skipDiagnostics` 选项的值为 `true`,这意味着打包过程中将跳过类型检查(一些项目通常有 `vue-tsc` 等的类型检查工具),这时如果出现存在类型错误的文件,并且这是错误会中断打包过程,那么这些文件对应的类型文件将不会被生成。
|
||||
|
||||
如果您的项目没有依赖外部的类型检查工具,这时候可以您可以设置 `skipDiagnostics: false` 和 `logDiagnostics: true` 来打开插件的诊断与输出功能,这将帮助您检查打包过程中出现的类型错误并将错误信息输出至终端。
|
||||
|
||||
### Vue 组件中同时使用了 `script` 和 `setup-script` 后出现类型错误(`3.0.0` 之前)
|
||||
|
||||
这通常是由于分别在 `script` 和 `setup-script` 中同时使用了 `defineComponent` 方法导致的。 `vue/compiler-sfc` 为这类文件编译时会将 `script` 中的默认导出结果合并到 `setup-script` 的 `defineComponent` 的参数定义中,而 `defineComponent` 的参数类型与结果类型并不兼容,这一行为将会导致类型错误。
|
||||
|
||||
这是一个简单的[示例](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue),您应该将位于 `script` 中的 `defineComponent` 方法移除,直接导出一个原始的对象。
|
||||
|
||||
</details>
|
||||
|
||||
## 选项
|
||||
|
||||
```ts
|
||||
import type ts from 'typescript'
|
||||
import type { IExtractorConfigPrepareOptions, IExtractorInvokeOptions } from '@microsoft/api-extractor'
|
||||
import type { LogLevel } from 'vite'
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>
|
||||
|
||||
export type RollupConfig = Omit<
|
||||
IExtractorConfigPrepareOptions['configObject'],
|
||||
| 'projectFolder'
|
||||
| 'mainEntryPointFilePath'
|
||||
| 'compiler'
|
||||
| 'dtsRollup'
|
||||
>
|
||||
|
||||
export interface Resolver {
|
||||
/**
|
||||
* 解析器的名称
|
||||
*
|
||||
* 靠后的同名解析器将会覆盖靠前的
|
||||
*/
|
||||
name: string,
|
||||
/**
|
||||
* 判断解析器是否支持该文件
|
||||
*/
|
||||
supports: (id: string) => void | boolean,
|
||||
/**
|
||||
* 将源文件转换为类型文件
|
||||
*
|
||||
* 注意,返回的文件的路径应该基于 `outDir`,或者相对于 `root`
|
||||
*/
|
||||
transform: (payload: {
|
||||
id: string,
|
||||
code: string,
|
||||
root: string,
|
||||
outDir: string,
|
||||
host: ts.CompilerHost,
|
||||
program: ts.Program,
|
||||
service: ts.LanguageService
|
||||
}) => MaybePromise<{ path: string, content: string }[]>
|
||||
}
|
||||
|
||||
export interface PluginOptions {
|
||||
/**
|
||||
* 指定根目录
|
||||
*
|
||||
* 默认为 Vite 配置的 'root',使用 Rollup 为 `process.cwd()`
|
||||
*/
|
||||
root?: string,
|
||||
|
||||
/**
|
||||
* 指定输出目录
|
||||
*
|
||||
* 可以指定一个数组来输出到多个目录中
|
||||
*
|
||||
* 默认为 Vite 配置的 'build.outDir',使用 Rollup 时为 tsconfig.json 的 `outDir`
|
||||
*/
|
||||
outDir?: string | string[],
|
||||
|
||||
/**
|
||||
* 用于手动设置入口文件的根路径(通常用在 monorepo)
|
||||
*
|
||||
* 在计算每个文件的输出路径时将基于该路径
|
||||
*
|
||||
* 默认为所有源文件的最小公共路径
|
||||
*/
|
||||
entryRoot?: string,
|
||||
|
||||
/**
|
||||
* 限制类型文件生成在 `outDir` 内
|
||||
*
|
||||
* 如果为 `true`,生成在 `outDir` 外的文件将被忽略
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
strictOutput?: boolean,
|
||||
|
||||
/**
|
||||
* 覆写 CompilerOptions
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
compilerOptions?: ts.CompilerOptions | null,
|
||||
|
||||
/**
|
||||
* 指定 tsconfig.json 的路径
|
||||
*
|
||||
* 插件会解析 tsconfig.json 的 include 和 exclude 选项
|
||||
*
|
||||
* 未指定时插件默认从根目录开始寻找配置文件
|
||||
*/
|
||||
tsconfigPath?: string,
|
||||
|
||||
/**
|
||||
* 指定自定义的解析器
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
resolvers?: Resolver[],
|
||||
|
||||
/**
|
||||
* 解析 tsconfig.json 的 `paths` 作为别名
|
||||
*
|
||||
* 注意,这些别名仅用在类型文件中使用
|
||||
*
|
||||
* @default true
|
||||
* @remarks 只使用每个路径的第一个替换
|
||||
*/
|
||||
pathsToAliases?: boolean,
|
||||
|
||||
/**
|
||||
* 设置在转换别名时哪些路径需要排除
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
aliasesExclude?: (string | RegExp)[],
|
||||
|
||||
/**
|
||||
* 是否将 '.vue.d.ts' 文件名转换为 '.d.ts'
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cleanVueFileName?: boolean,
|
||||
|
||||
/**
|
||||
* 是否将动态引入转换为静态(例如:`import('vue').DefineComponent` 转换为 `import { DefineComponent } from 'vue'`)
|
||||
*
|
||||
* 开启 `rollupTypes` 时强制为 `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
staticImport?: boolean,
|
||||
|
||||
/**
|
||||
* 手动设置包含路径的 glob(相对于 root)
|
||||
*
|
||||
* 默认基于 tsconfig.json 的 `include` 选项(相对于 tsconfig.json 所在目录)
|
||||
*/
|
||||
include?: string | string[],
|
||||
|
||||
/**
|
||||
* 手动设置排除路径的 glob
|
||||
*
|
||||
* 默认基于 tsconfig.json 的 `exclude` 选线,未设置时为 `'node_modules/**'`
|
||||
*/
|
||||
exclude?: string | string[],
|
||||
|
||||
/**
|
||||
* 是否移除 `import 'xxx'`
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
clearPureImport?: boolean,
|
||||
|
||||
/**
|
||||
* 是否生成类型入口文件
|
||||
*
|
||||
* 当为 `true` 时会基于 package.json 的 `types` 字段生成,或者 `${outDir}/index.d.ts`
|
||||
*
|
||||
* 当开启 `rollupTypes` 时强制为 `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
insertTypesEntry?: boolean,
|
||||
|
||||
/**
|
||||
* 设置是否在发出类型文件后将其打包
|
||||
*
|
||||
* 基于 `@microsoft/api-extractor`,过程将会消耗一些时间
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
rollupTypes?: boolean,
|
||||
|
||||
/**
|
||||
* 设置 `@microsoft/api-extractor` 的 `bundledPackages` 选项
|
||||
*
|
||||
* @default []
|
||||
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
||||
*/
|
||||
bundledPackages?: string[],
|
||||
|
||||
/**
|
||||
* 覆写 `@microsoft/api-extractor` 的配置
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
||||
*/
|
||||
rollupConfig?: RollupConfig,
|
||||
|
||||
/**
|
||||
* 覆写 `@microsoft/api-extractor` 的调用选项
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
|
||||
*/
|
||||
rollupOptions?: IExtractorInvokeOptions,
|
||||
|
||||
/**
|
||||
* 是否将源码里的 .d.ts 文件复制到 `outDir`
|
||||
*
|
||||
* @default false
|
||||
* @remarks 在 2.0 之前它默认为 `true`
|
||||
*/
|
||||
copyDtsFiles?: boolean,
|
||||
|
||||
/**
|
||||
* 是否只生成类型文件
|
||||
*
|
||||
* 当为 `true` 时会强制删除所有 Vite(Rollup)的原始产物
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
declarationOnly?: boolean,
|
||||
|
||||
/**
|
||||
* 指定插件的输出等级
|
||||
*
|
||||
* 默认基于 Vite 配置的 'logLevel' 选项
|
||||
*/
|
||||
logLevel?: LogLevel,
|
||||
|
||||
/**
|
||||
* 获取诊断信息后的钩子
|
||||
*
|
||||
* 可以根据 `diagnostics.length` 来判断有误类型错误
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
|
||||
|
||||
/**
|
||||
* 类型声明文件被写入前的钩子
|
||||
*
|
||||
* 可以在钩子里转换文件路径和文件内容
|
||||
*
|
||||
* 当返回 `false` 或 `Promise<false>` 时会跳过该文件
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
beforeWriteFile?: (
|
||||
filePath: string,
|
||||
content: string
|
||||
) => MaybePromise<
|
||||
| void
|
||||
| false
|
||||
| {
|
||||
filePath?: string,
|
||||
content?: string
|
||||
}
|
||||
>,
|
||||
|
||||
/**
|
||||
* 在所有类型文件被写入后调用的钩子
|
||||
*
|
||||
* 它会接收一个记录了那些最终被写入的文件的映射(path -> content)
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>
|
||||
}
|
||||
```
|
||||
|
||||
## 贡献者
|
||||
|
||||
感谢他们的所做的一切贡献!
|
||||
|
||||
<a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
|
||||
</a>
|
||||
|
||||
## 示例
|
||||
|
||||
克隆项目然后执行下列命令:
|
||||
|
||||
```sh
|
||||
pnpm run test:ts
|
||||
```
|
||||
|
||||
然后检查 `examples/ts/types` 目录。
|
||||
|
||||
`examples` 目录下同样有 Vue 和 React 的案例。
|
||||
|
||||
一个使用该插件的真实项目:[Vexip UI](https://github.com/vexip-ui/vexip-ui)。
|
||||
|
||||
## 授权
|
||||
|
||||
MIT 授权。
|
1043
node_modules/vite-plugin-dts/dist/index.cjs
generated
vendored
Normal file
1043
node_modules/vite-plugin-dts/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
230
node_modules/vite-plugin-dts/dist/index.d.cts
generated
vendored
Normal file
230
node_modules/vite-plugin-dts/dist/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
import * as vite from 'vite';
|
||||
import { LogLevel } from 'vite';
|
||||
import ts from 'typescript';
|
||||
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
||||
interface Resolver {
|
||||
/**
|
||||
* The name of the resolver
|
||||
*
|
||||
* The later resolver with the same name will overwrite the earlier
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Determine whether the resolver supports the file
|
||||
*/
|
||||
supports: (id: string) => void | boolean;
|
||||
/**
|
||||
* Transform source to declaration files
|
||||
*
|
||||
* Note that the path of the returns should base on `outDir`, or relative path to `root`
|
||||
*/
|
||||
transform: (payload: {
|
||||
id: string;
|
||||
code: string;
|
||||
root: string;
|
||||
outDir: string;
|
||||
host: ts.CompilerHost;
|
||||
program: ts.Program;
|
||||
service: ts.LanguageService;
|
||||
}) => MaybePromise<{
|
||||
path: string;
|
||||
content: string;
|
||||
}[]>;
|
||||
}
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* Specify root directory
|
||||
*
|
||||
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Output directory for declaration files
|
||||
*
|
||||
* Can be an array to output to multiple directories
|
||||
*
|
||||
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
||||
*/
|
||||
outDir?: string | string[];
|
||||
/**
|
||||
* Override root path of entry files (useful in monorepos)
|
||||
*
|
||||
* The output path of each file will be calculated based on the value provided
|
||||
*
|
||||
* The default is the smallest public path for all source files
|
||||
*/
|
||||
entryRoot?: string;
|
||||
/**
|
||||
* Restrict declaration files output to `outDir`
|
||||
*
|
||||
* If true, generated declaration files outside `outDir` will be ignored
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
strictOutput?: boolean;
|
||||
/**
|
||||
* Override compilerOptions
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
compilerOptions?: ts.CompilerOptions | null;
|
||||
/**
|
||||
* Specify tsconfig.json path
|
||||
*
|
||||
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
||||
*
|
||||
* If not specified, plugin will find config file from root
|
||||
*/
|
||||
tsconfigPath?: string;
|
||||
/**
|
||||
* Specify custom resolvers
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
resolvers?: Resolver[];
|
||||
/**
|
||||
* Parsing `paths` of tsconfig.json to aliases
|
||||
*
|
||||
* Note that these aliases only use for declaration files
|
||||
*
|
||||
* @default true
|
||||
* @remarks Only use first replacement of each path
|
||||
*/
|
||||
pathsToAliases?: boolean;
|
||||
/**
|
||||
* Set which paths should be excluded when transforming aliases
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
aliasesExclude?: (string | RegExp)[];
|
||||
/**
|
||||
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cleanVueFileName?: boolean;
|
||||
/**
|
||||
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
staticImport?: boolean;
|
||||
/**
|
||||
* Override `include` glob (relative to root)
|
||||
*
|
||||
* Defaults to `include` property of tsconfig.json (relative to tsconfig.json located)
|
||||
*/
|
||||
include?: string | string[];
|
||||
/**
|
||||
* Override `exclude` glob
|
||||
*
|
||||
* Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
|
||||
*/
|
||||
exclude?: string | string[];
|
||||
/**
|
||||
* Whether to remove `import 'xxx'`
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
clearPureImport?: boolean;
|
||||
/**
|
||||
* Whether to generate types entry file(s)
|
||||
*
|
||||
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
insertTypesEntry?: boolean;
|
||||
/**
|
||||
* Rollup type declaration files after emitting them
|
||||
*
|
||||
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
rollupTypes?: boolean;
|
||||
/**
|
||||
* Bundled packages for `@microsoft/api-extractor`
|
||||
*
|
||||
* @default []
|
||||
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
||||
*/
|
||||
bundledPackages?: string[];
|
||||
/**
|
||||
* Override the config of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
||||
*/
|
||||
rollupConfig?: RollupConfig;
|
||||
/**
|
||||
* Override the invoke options of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
|
||||
*/
|
||||
rollupOptions?: IExtractorInvokeOptions;
|
||||
/**
|
||||
* Whether to copy .d.ts source files to `outDir`
|
||||
*
|
||||
* @default false
|
||||
* @remarks Before 2.0, the default was `true`
|
||||
*/
|
||||
copyDtsFiles?: boolean;
|
||||
/**
|
||||
* Whether to emit declaration files only
|
||||
*
|
||||
* When `true`, all the original outputs of vite (rollup) will be force removed
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
declarationOnly?: boolean;
|
||||
/**
|
||||
* Logging level for this plugin
|
||||
*
|
||||
* Defaults to the 'logLevel' property of your Vite config
|
||||
*/
|
||||
logLevel?: LogLevel;
|
||||
/**
|
||||
* Hook called after diagnostic is emitted
|
||||
*
|
||||
* According to the `diagnostics.length`, you can judge whether there is any type error
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>;
|
||||
/**
|
||||
* Hook called prior to writing each declaration file
|
||||
*
|
||||
* This allows you to transform the path or content
|
||||
*
|
||||
* The file will be skipped when the return value `false` or `Promise<false>`
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
beforeWriteFile?: (filePath: string, content: string) => MaybePromise<void | false | {
|
||||
filePath?: string;
|
||||
content?: string;
|
||||
}>;
|
||||
/**
|
||||
* Hook called after all declaration files are written
|
||||
*
|
||||
* It will be received a map (path -> content) that records those emitted files
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
|
||||
}
|
||||
|
||||
declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
|
||||
|
||||
declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
|
||||
|
||||
export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
|
230
node_modules/vite-plugin-dts/dist/index.d.mts
generated
vendored
Normal file
230
node_modules/vite-plugin-dts/dist/index.d.mts
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
import * as vite from 'vite';
|
||||
import { LogLevel } from 'vite';
|
||||
import ts from 'typescript';
|
||||
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
||||
interface Resolver {
|
||||
/**
|
||||
* The name of the resolver
|
||||
*
|
||||
* The later resolver with the same name will overwrite the earlier
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Determine whether the resolver supports the file
|
||||
*/
|
||||
supports: (id: string) => void | boolean;
|
||||
/**
|
||||
* Transform source to declaration files
|
||||
*
|
||||
* Note that the path of the returns should base on `outDir`, or relative path to `root`
|
||||
*/
|
||||
transform: (payload: {
|
||||
id: string;
|
||||
code: string;
|
||||
root: string;
|
||||
outDir: string;
|
||||
host: ts.CompilerHost;
|
||||
program: ts.Program;
|
||||
service: ts.LanguageService;
|
||||
}) => MaybePromise<{
|
||||
path: string;
|
||||
content: string;
|
||||
}[]>;
|
||||
}
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* Specify root directory
|
||||
*
|
||||
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Output directory for declaration files
|
||||
*
|
||||
* Can be an array to output to multiple directories
|
||||
*
|
||||
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
||||
*/
|
||||
outDir?: string | string[];
|
||||
/**
|
||||
* Override root path of entry files (useful in monorepos)
|
||||
*
|
||||
* The output path of each file will be calculated based on the value provided
|
||||
*
|
||||
* The default is the smallest public path for all source files
|
||||
*/
|
||||
entryRoot?: string;
|
||||
/**
|
||||
* Restrict declaration files output to `outDir`
|
||||
*
|
||||
* If true, generated declaration files outside `outDir` will be ignored
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
strictOutput?: boolean;
|
||||
/**
|
||||
* Override compilerOptions
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
compilerOptions?: ts.CompilerOptions | null;
|
||||
/**
|
||||
* Specify tsconfig.json path
|
||||
*
|
||||
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
||||
*
|
||||
* If not specified, plugin will find config file from root
|
||||
*/
|
||||
tsconfigPath?: string;
|
||||
/**
|
||||
* Specify custom resolvers
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
resolvers?: Resolver[];
|
||||
/**
|
||||
* Parsing `paths` of tsconfig.json to aliases
|
||||
*
|
||||
* Note that these aliases only use for declaration files
|
||||
*
|
||||
* @default true
|
||||
* @remarks Only use first replacement of each path
|
||||
*/
|
||||
pathsToAliases?: boolean;
|
||||
/**
|
||||
* Set which paths should be excluded when transforming aliases
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
aliasesExclude?: (string | RegExp)[];
|
||||
/**
|
||||
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cleanVueFileName?: boolean;
|
||||
/**
|
||||
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
staticImport?: boolean;
|
||||
/**
|
||||
* Override `include` glob (relative to root)
|
||||
*
|
||||
* Defaults to `include` property of tsconfig.json (relative to tsconfig.json located)
|
||||
*/
|
||||
include?: string | string[];
|
||||
/**
|
||||
* Override `exclude` glob
|
||||
*
|
||||
* Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
|
||||
*/
|
||||
exclude?: string | string[];
|
||||
/**
|
||||
* Whether to remove `import 'xxx'`
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
clearPureImport?: boolean;
|
||||
/**
|
||||
* Whether to generate types entry file(s)
|
||||
*
|
||||
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
insertTypesEntry?: boolean;
|
||||
/**
|
||||
* Rollup type declaration files after emitting them
|
||||
*
|
||||
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
rollupTypes?: boolean;
|
||||
/**
|
||||
* Bundled packages for `@microsoft/api-extractor`
|
||||
*
|
||||
* @default []
|
||||
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
||||
*/
|
||||
bundledPackages?: string[];
|
||||
/**
|
||||
* Override the config of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
||||
*/
|
||||
rollupConfig?: RollupConfig;
|
||||
/**
|
||||
* Override the invoke options of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
|
||||
*/
|
||||
rollupOptions?: IExtractorInvokeOptions;
|
||||
/**
|
||||
* Whether to copy .d.ts source files to `outDir`
|
||||
*
|
||||
* @default false
|
||||
* @remarks Before 2.0, the default was `true`
|
||||
*/
|
||||
copyDtsFiles?: boolean;
|
||||
/**
|
||||
* Whether to emit declaration files only
|
||||
*
|
||||
* When `true`, all the original outputs of vite (rollup) will be force removed
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
declarationOnly?: boolean;
|
||||
/**
|
||||
* Logging level for this plugin
|
||||
*
|
||||
* Defaults to the 'logLevel' property of your Vite config
|
||||
*/
|
||||
logLevel?: LogLevel;
|
||||
/**
|
||||
* Hook called after diagnostic is emitted
|
||||
*
|
||||
* According to the `diagnostics.length`, you can judge whether there is any type error
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>;
|
||||
/**
|
||||
* Hook called prior to writing each declaration file
|
||||
*
|
||||
* This allows you to transform the path or content
|
||||
*
|
||||
* The file will be skipped when the return value `false` or `Promise<false>`
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
beforeWriteFile?: (filePath: string, content: string) => MaybePromise<void | false | {
|
||||
filePath?: string;
|
||||
content?: string;
|
||||
}>;
|
||||
/**
|
||||
* Hook called after all declaration files are written
|
||||
*
|
||||
* It will be received a map (path -> content) that records those emitted files
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
|
||||
}
|
||||
|
||||
declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
|
||||
|
||||
declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
|
||||
|
||||
export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
|
230
node_modules/vite-plugin-dts/dist/index.d.ts
generated
vendored
Normal file
230
node_modules/vite-plugin-dts/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,230 @@
|
||||
import * as vite from 'vite';
|
||||
import { LogLevel } from 'vite';
|
||||
import ts from 'typescript';
|
||||
import { IExtractorInvokeOptions, IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
||||
interface Resolver {
|
||||
/**
|
||||
* The name of the resolver
|
||||
*
|
||||
* The later resolver with the same name will overwrite the earlier
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Determine whether the resolver supports the file
|
||||
*/
|
||||
supports: (id: string) => void | boolean;
|
||||
/**
|
||||
* Transform source to declaration files
|
||||
*
|
||||
* Note that the path of the returns should base on `outDir`, or relative path to `root`
|
||||
*/
|
||||
transform: (payload: {
|
||||
id: string;
|
||||
code: string;
|
||||
root: string;
|
||||
outDir: string;
|
||||
host: ts.CompilerHost;
|
||||
program: ts.Program;
|
||||
service: ts.LanguageService;
|
||||
}) => MaybePromise<{
|
||||
path: string;
|
||||
content: string;
|
||||
}[]>;
|
||||
}
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* Specify root directory
|
||||
*
|
||||
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Output directory for declaration files
|
||||
*
|
||||
* Can be an array to output to multiple directories
|
||||
*
|
||||
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
||||
*/
|
||||
outDir?: string | string[];
|
||||
/**
|
||||
* Override root path of entry files (useful in monorepos)
|
||||
*
|
||||
* The output path of each file will be calculated based on the value provided
|
||||
*
|
||||
* The default is the smallest public path for all source files
|
||||
*/
|
||||
entryRoot?: string;
|
||||
/**
|
||||
* Restrict declaration files output to `outDir`
|
||||
*
|
||||
* If true, generated declaration files outside `outDir` will be ignored
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
strictOutput?: boolean;
|
||||
/**
|
||||
* Override compilerOptions
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
compilerOptions?: ts.CompilerOptions | null;
|
||||
/**
|
||||
* Specify tsconfig.json path
|
||||
*
|
||||
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
||||
*
|
||||
* If not specified, plugin will find config file from root
|
||||
*/
|
||||
tsconfigPath?: string;
|
||||
/**
|
||||
* Specify custom resolvers
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
resolvers?: Resolver[];
|
||||
/**
|
||||
* Parsing `paths` of tsconfig.json to aliases
|
||||
*
|
||||
* Note that these aliases only use for declaration files
|
||||
*
|
||||
* @default true
|
||||
* @remarks Only use first replacement of each path
|
||||
*/
|
||||
pathsToAliases?: boolean;
|
||||
/**
|
||||
* Set which paths should be excluded when transforming aliases
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
aliasesExclude?: (string | RegExp)[];
|
||||
/**
|
||||
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cleanVueFileName?: boolean;
|
||||
/**
|
||||
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
staticImport?: boolean;
|
||||
/**
|
||||
* Override `include` glob (relative to root)
|
||||
*
|
||||
* Defaults to `include` property of tsconfig.json (relative to tsconfig.json located)
|
||||
*/
|
||||
include?: string | string[];
|
||||
/**
|
||||
* Override `exclude` glob
|
||||
*
|
||||
* Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
|
||||
*/
|
||||
exclude?: string | string[];
|
||||
/**
|
||||
* Whether to remove `import 'xxx'`
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
clearPureImport?: boolean;
|
||||
/**
|
||||
* Whether to generate types entry file(s)
|
||||
*
|
||||
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
||||
*
|
||||
* Value is forced to `true` when `rollupTypes` is `true`
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
insertTypesEntry?: boolean;
|
||||
/**
|
||||
* Rollup type declaration files after emitting them
|
||||
*
|
||||
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
rollupTypes?: boolean;
|
||||
/**
|
||||
* Bundled packages for `@microsoft/api-extractor`
|
||||
*
|
||||
* @default []
|
||||
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
||||
*/
|
||||
bundledPackages?: string[];
|
||||
/**
|
||||
* Override the config of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
||||
*/
|
||||
rollupConfig?: RollupConfig;
|
||||
/**
|
||||
* Override the invoke options of `@microsoft/api-extractor`
|
||||
*
|
||||
* @default null
|
||||
* @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
|
||||
*/
|
||||
rollupOptions?: IExtractorInvokeOptions;
|
||||
/**
|
||||
* Whether to copy .d.ts source files to `outDir`
|
||||
*
|
||||
* @default false
|
||||
* @remarks Before 2.0, the default was `true`
|
||||
*/
|
||||
copyDtsFiles?: boolean;
|
||||
/**
|
||||
* Whether to emit declaration files only
|
||||
*
|
||||
* When `true`, all the original outputs of vite (rollup) will be force removed
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
declarationOnly?: boolean;
|
||||
/**
|
||||
* Logging level for this plugin
|
||||
*
|
||||
* Defaults to the 'logLevel' property of your Vite config
|
||||
*/
|
||||
logLevel?: LogLevel;
|
||||
/**
|
||||
* Hook called after diagnostic is emitted
|
||||
*
|
||||
* According to the `diagnostics.length`, you can judge whether there is any type error
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>;
|
||||
/**
|
||||
* Hook called prior to writing each declaration file
|
||||
*
|
||||
* This allows you to transform the path or content
|
||||
*
|
||||
* The file will be skipped when the return value `false` or `Promise<false>`
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
beforeWriteFile?: (filePath: string, content: string) => MaybePromise<void | false | {
|
||||
filePath?: string;
|
||||
content?: string;
|
||||
}>;
|
||||
/**
|
||||
* Hook called after all declaration files are written
|
||||
*
|
||||
* It will be received a map (path -> content) that records those emitted files
|
||||
*
|
||||
* @default () => {}
|
||||
*/
|
||||
afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>;
|
||||
}
|
||||
|
||||
declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
|
||||
|
||||
declare function editSourceMapDir(content: string, fromDir: string, toDir: string): string | boolean;
|
||||
|
||||
export { type PluginOptions, dtsPlugin as default, editSourceMapDir };
|
1040
node_modules/vite-plugin-dts/dist/index.mjs
generated
vendored
Normal file
1040
node_modules/vite-plugin-dts/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
113
node_modules/vite-plugin-dts/package.json
generated
vendored
Normal file
113
node_modules/vite-plugin-dts/package.json
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"name": "vite-plugin-dts",
|
||||
"version": "3.7.2",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "qmhc",
|
||||
"packageManager": "pnpm@8.3.0",
|
||||
"scripts": {
|
||||
"build": "tsx scripts/build.ts",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
|
||||
"dev": "unbuild --stub",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx \"{src,tests}/**\"",
|
||||
"_postinstall": "is-ci || husky install",
|
||||
"postpublish": "pinst --enable",
|
||||
"precommit": "lint-staged -c ./.husky/.lintstagedrc -q",
|
||||
"prepublishOnly": "pinst --disable",
|
||||
"prettier": "pretty-quick --staged && pnpm run lint",
|
||||
"release": "tsx scripts/release.ts",
|
||||
"test": "vitest run",
|
||||
"test:dev": "vitest",
|
||||
"test:react": "pnpm -C examples/react build",
|
||||
"test:svelte": "pnpm -C examples/svelte build",
|
||||
"test:ts": "pnpm -C examples/ts build",
|
||||
"test:vue": "pnpm -C examples/vue build"
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/qmhc/vite-plugin-dts.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/qmhc/vite-plugin-dts/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"vite",
|
||||
"vite-plugin",
|
||||
"ts",
|
||||
"dts",
|
||||
"typescript",
|
||||
"vue",
|
||||
"tsc",
|
||||
"vue-tsc",
|
||||
"volar"
|
||||
],
|
||||
"dependencies": {
|
||||
"@microsoft/api-extractor": "7.39.0",
|
||||
"@rollup/pluginutils": "^5.1.0",
|
||||
"@vue/language-core": "^1.8.26",
|
||||
"debug": "^4.3.4",
|
||||
"kolorist": "^1.8.0",
|
||||
"vue-tsc": "^1.8.26"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^18.4.3",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/minimist": "^1.2.5",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/prompts": "^2.4.9",
|
||||
"@types/semver": "^7.5.6",
|
||||
"@vexip-ui/commitlint-config": "^0.3.0",
|
||||
"@vexip-ui/eslint-config": "^0.11.0",
|
||||
"@vexip-ui/prettier-config": "^0.2.0",
|
||||
"@vue/eslint-config-standard": "^8.0.1",
|
||||
"@vue/eslint-config-typescript": "^12.0.0",
|
||||
"conventional-changelog-cli": "^4.1.0",
|
||||
"eslint": "^8.56.0",
|
||||
"execa": "^8.0.1",
|
||||
"husky": "^8.0.3",
|
||||
"is-ci": "^3.0.1",
|
||||
"lint-staged": "^15.2.0",
|
||||
"minimist": "^1.2.8",
|
||||
"pinst": "^3.0.0",
|
||||
"prettier": "^3.1.1",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"prompts": "^2.4.2",
|
||||
"rimraf": "^5.0.5",
|
||||
"semver": "^7.5.4",
|
||||
"tsx": "^4.7.0",
|
||||
"typescript": "5.2.2",
|
||||
"unbuild": "^2.0.0",
|
||||
"vite": "^5.0.10",
|
||||
"vitest": "^1.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "*",
|
||||
"vite": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@microsoft/api-extractor@7.39.0": "patches/@microsoft__api-extractor@7.39.0.patch"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user