vite-plugin-dts 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/README.zh-CN.md +17 -0
- package/dist/index.cjs +15 -10
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +15 -10
- package/package.json +14 -17
package/README.md
CHANGED
|
@@ -80,10 +80,19 @@ This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/i
|
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
82
|
import type ts from 'typescript'
|
|
83
|
+
import type { IExtractorConfigPrepareOptions } from '@microsoft/api-extractor'
|
|
83
84
|
import type { LogLevel } from 'vite'
|
|
84
85
|
|
|
85
86
|
type MaybePromise<T> = T | Promise<T>
|
|
86
87
|
|
|
88
|
+
export type RollupConfig = Omit<
|
|
89
|
+
IExtractorConfigPrepareOptions['configObject'],
|
|
90
|
+
| 'projectFolder'
|
|
91
|
+
| 'mainEntryPointFilePath'
|
|
92
|
+
| 'compiler'
|
|
93
|
+
| 'dtsRollup'
|
|
94
|
+
>
|
|
95
|
+
|
|
87
96
|
export interface Resolver {
|
|
88
97
|
/**
|
|
89
98
|
* The name of the resolver
|
|
@@ -251,6 +260,14 @@ export interface PluginOptions {
|
|
|
251
260
|
*/
|
|
252
261
|
bundledPackages?: string[],
|
|
253
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Override the config of `@microsoft/api-extractor`
|
|
265
|
+
*
|
|
266
|
+
* @default null
|
|
267
|
+
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
|
268
|
+
*/
|
|
269
|
+
rollupConfig?: RollupConfig,
|
|
270
|
+
|
|
254
271
|
/**
|
|
255
272
|
* Whether to copy .d.ts source files to `outDir`
|
|
256
273
|
*
|
package/README.zh-CN.md
CHANGED
|
@@ -80,10 +80,19 @@ export default defineConfig({
|
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
82
|
import type ts from 'typescript'
|
|
83
|
+
import type { IExtractorConfigPrepareOptions } from '@microsoft/api-extractor'
|
|
83
84
|
import type { LogLevel } from 'vite'
|
|
84
85
|
|
|
85
86
|
type MaybePromise<T> = T | Promise<T>
|
|
86
87
|
|
|
88
|
+
export type RollupConfig = Omit<
|
|
89
|
+
IExtractorConfigPrepareOptions['configObject'],
|
|
90
|
+
| 'projectFolder'
|
|
91
|
+
| 'mainEntryPointFilePath'
|
|
92
|
+
| 'compiler'
|
|
93
|
+
| 'dtsRollup'
|
|
94
|
+
>
|
|
95
|
+
|
|
87
96
|
export interface Resolver {
|
|
88
97
|
/**
|
|
89
98
|
* 解析器的名称
|
|
@@ -251,6 +260,14 @@ export interface PluginOptions {
|
|
|
251
260
|
*/
|
|
252
261
|
bundledPackages?: string[],
|
|
253
262
|
|
|
263
|
+
/**
|
|
264
|
+
* 覆写 `@microsoft/api-extractor` 的配置
|
|
265
|
+
*
|
|
266
|
+
* @default null
|
|
267
|
+
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
|
268
|
+
*/
|
|
269
|
+
rollupConfig?: RollupConfig,
|
|
270
|
+
|
|
254
271
|
/**
|
|
255
272
|
* 是否将源码里的 .d.ts 文件复制到 `outDir`
|
|
256
273
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -185,7 +185,7 @@ function rollupDeclarationFiles({
|
|
|
185
185
|
entryPath,
|
|
186
186
|
fileName,
|
|
187
187
|
libFolder,
|
|
188
|
-
|
|
188
|
+
rollupConfig = {}
|
|
189
189
|
}) {
|
|
190
190
|
const configObjectFullPath = node_path.resolve(root, "api-extractor.json");
|
|
191
191
|
if (!dtsRE$1.test(fileName)) {
|
|
@@ -193,9 +193,9 @@ function rollupDeclarationFiles({
|
|
|
193
193
|
}
|
|
194
194
|
const extractorConfig = apiExtractor.ExtractorConfig.prepare({
|
|
195
195
|
configObject: {
|
|
196
|
+
...rollupConfig,
|
|
196
197
|
projectFolder: root,
|
|
197
198
|
mainEntryPointFilePath: entryPath,
|
|
198
|
-
bundledPackages,
|
|
199
199
|
compiler: {
|
|
200
200
|
tsconfigFilePath: configPath,
|
|
201
201
|
overrideTsconfig: {
|
|
@@ -205,17 +205,20 @@ function rollupDeclarationFiles({
|
|
|
205
205
|
},
|
|
206
206
|
apiReport: {
|
|
207
207
|
enabled: false,
|
|
208
|
-
reportFileName: "<unscopedPackageName>.api.md"
|
|
208
|
+
reportFileName: "<unscopedPackageName>.api.md",
|
|
209
|
+
...rollupConfig.apiReport
|
|
209
210
|
},
|
|
210
211
|
docModel: {
|
|
211
|
-
enabled: false
|
|
212
|
+
enabled: false,
|
|
213
|
+
...rollupConfig.docModel
|
|
212
214
|
},
|
|
213
215
|
dtsRollup: {
|
|
214
216
|
enabled: true,
|
|
215
217
|
publicTrimmedFilePath: node_path.resolve(outDir, fileName)
|
|
216
218
|
},
|
|
217
219
|
tsdocMetadata: {
|
|
218
|
-
enabled: false
|
|
220
|
+
enabled: false,
|
|
221
|
+
...rollupConfig.tsdocMetadata
|
|
219
222
|
},
|
|
220
223
|
messages: {
|
|
221
224
|
compilerMessageReporting: {
|
|
@@ -227,7 +230,8 @@ function rollupDeclarationFiles({
|
|
|
227
230
|
default: {
|
|
228
231
|
logLevel: "none"
|
|
229
232
|
}
|
|
230
|
-
}
|
|
233
|
+
},
|
|
234
|
+
...rollupConfig.messages
|
|
231
235
|
}
|
|
232
236
|
},
|
|
233
237
|
configObjectFullPath,
|
|
@@ -464,7 +468,6 @@ function dtsPlugin(options = {}) {
|
|
|
464
468
|
cleanVueFileName = false,
|
|
465
469
|
insertTypesEntry = false,
|
|
466
470
|
rollupTypes = false,
|
|
467
|
-
bundledPackages = [],
|
|
468
471
|
pathsToAliases = true,
|
|
469
472
|
aliasesExclude = [],
|
|
470
473
|
copyDtsFiles = false,
|
|
@@ -500,6 +503,8 @@ function dtsPlugin(options = {}) {
|
|
|
500
503
|
]);
|
|
501
504
|
const rootFiles = /* @__PURE__ */ new Set();
|
|
502
505
|
const outputFiles = /* @__PURE__ */ new Map();
|
|
506
|
+
const rollupConfig = { ...options.rollupConfig || {} };
|
|
507
|
+
rollupConfig.bundledPackages = rollupConfig.bundledPackages || options.bundledPackages || [];
|
|
503
508
|
return {
|
|
504
509
|
name: "vite:dts",
|
|
505
510
|
apply: "build",
|
|
@@ -674,7 +679,7 @@ ${kolorist.cyan(
|
|
|
674
679
|
} else {
|
|
675
680
|
const sourceFile = program.getSourceFile(id);
|
|
676
681
|
if (sourceFile) {
|
|
677
|
-
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
682
|
+
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true, true).outputFiles) {
|
|
678
683
|
outputFiles.set(
|
|
679
684
|
resolve(publicRoot, node_path.relative(outDir, ensureAbsolute(outputFile.name, outDir))),
|
|
680
685
|
outputFile.text
|
|
@@ -847,7 +852,7 @@ export default ${libName}
|
|
|
847
852
|
entryPath: path,
|
|
848
853
|
fileName: node_path.basename(path),
|
|
849
854
|
libFolder,
|
|
850
|
-
|
|
855
|
+
rollupConfig
|
|
851
856
|
});
|
|
852
857
|
emittedFiles.delete(path);
|
|
853
858
|
rollupFiles.add(path);
|
|
@@ -861,7 +866,7 @@ export default ${libName}
|
|
|
861
866
|
entryPath: typesPath,
|
|
862
867
|
fileName: node_path.basename(typesPath),
|
|
863
868
|
libFolder,
|
|
864
|
-
|
|
869
|
+
rollupConfig
|
|
865
870
|
});
|
|
866
871
|
emittedFiles.delete(typesPath);
|
|
867
872
|
rollupFiles.add(typesPath);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { LogLevel } from 'vite';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
+
import { IExtractorConfigPrepareOptions } from '@microsoft/api-extractor';
|
|
4
5
|
|
|
5
6
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
type RollupConfig = Omit<IExtractorConfigPrepareOptions['configObject'], 'projectFolder' | 'mainEntryPointFilePath' | 'compiler' | 'dtsRollup'>;
|
|
6
8
|
interface Resolver {
|
|
7
9
|
/**
|
|
8
10
|
* The name of the resolver
|
|
@@ -155,6 +157,13 @@ interface PluginOptions {
|
|
|
155
157
|
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
|
156
158
|
*/
|
|
157
159
|
bundledPackages?: string[];
|
|
160
|
+
/**
|
|
161
|
+
* Override the config of `@microsoft/api-extractor`
|
|
162
|
+
*
|
|
163
|
+
* @default null
|
|
164
|
+
* @see https://api-extractor.com/pages/setup/configure_api_report/
|
|
165
|
+
*/
|
|
166
|
+
rollupConfig?: RollupConfig;
|
|
158
167
|
/**
|
|
159
168
|
* Whether to copy .d.ts source files to `outDir`
|
|
160
169
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -185,7 +185,7 @@ function rollupDeclarationFiles({
|
|
|
185
185
|
entryPath,
|
|
186
186
|
fileName,
|
|
187
187
|
libFolder,
|
|
188
|
-
|
|
188
|
+
rollupConfig = {}
|
|
189
189
|
}) {
|
|
190
190
|
const configObjectFullPath = resolve$1(root, "api-extractor.json");
|
|
191
191
|
if (!dtsRE$1.test(fileName)) {
|
|
@@ -193,9 +193,9 @@ function rollupDeclarationFiles({
|
|
|
193
193
|
}
|
|
194
194
|
const extractorConfig = ExtractorConfig.prepare({
|
|
195
195
|
configObject: {
|
|
196
|
+
...rollupConfig,
|
|
196
197
|
projectFolder: root,
|
|
197
198
|
mainEntryPointFilePath: entryPath,
|
|
198
|
-
bundledPackages,
|
|
199
199
|
compiler: {
|
|
200
200
|
tsconfigFilePath: configPath,
|
|
201
201
|
overrideTsconfig: {
|
|
@@ -205,17 +205,20 @@ function rollupDeclarationFiles({
|
|
|
205
205
|
},
|
|
206
206
|
apiReport: {
|
|
207
207
|
enabled: false,
|
|
208
|
-
reportFileName: "<unscopedPackageName>.api.md"
|
|
208
|
+
reportFileName: "<unscopedPackageName>.api.md",
|
|
209
|
+
...rollupConfig.apiReport
|
|
209
210
|
},
|
|
210
211
|
docModel: {
|
|
211
|
-
enabled: false
|
|
212
|
+
enabled: false,
|
|
213
|
+
...rollupConfig.docModel
|
|
212
214
|
},
|
|
213
215
|
dtsRollup: {
|
|
214
216
|
enabled: true,
|
|
215
217
|
publicTrimmedFilePath: resolve$1(outDir, fileName)
|
|
216
218
|
},
|
|
217
219
|
tsdocMetadata: {
|
|
218
|
-
enabled: false
|
|
220
|
+
enabled: false,
|
|
221
|
+
...rollupConfig.tsdocMetadata
|
|
219
222
|
},
|
|
220
223
|
messages: {
|
|
221
224
|
compilerMessageReporting: {
|
|
@@ -227,7 +230,8 @@ function rollupDeclarationFiles({
|
|
|
227
230
|
default: {
|
|
228
231
|
logLevel: "none"
|
|
229
232
|
}
|
|
230
|
-
}
|
|
233
|
+
},
|
|
234
|
+
...rollupConfig.messages
|
|
231
235
|
}
|
|
232
236
|
},
|
|
233
237
|
configObjectFullPath,
|
|
@@ -464,7 +468,6 @@ function dtsPlugin(options = {}) {
|
|
|
464
468
|
cleanVueFileName = false,
|
|
465
469
|
insertTypesEntry = false,
|
|
466
470
|
rollupTypes = false,
|
|
467
|
-
bundledPackages = [],
|
|
468
471
|
pathsToAliases = true,
|
|
469
472
|
aliasesExclude = [],
|
|
470
473
|
copyDtsFiles = false,
|
|
@@ -500,6 +503,8 @@ function dtsPlugin(options = {}) {
|
|
|
500
503
|
]);
|
|
501
504
|
const rootFiles = /* @__PURE__ */ new Set();
|
|
502
505
|
const outputFiles = /* @__PURE__ */ new Map();
|
|
506
|
+
const rollupConfig = { ...options.rollupConfig || {} };
|
|
507
|
+
rollupConfig.bundledPackages = rollupConfig.bundledPackages || options.bundledPackages || [];
|
|
503
508
|
return {
|
|
504
509
|
name: "vite:dts",
|
|
505
510
|
apply: "build",
|
|
@@ -674,7 +679,7 @@ ${cyan(
|
|
|
674
679
|
} else {
|
|
675
680
|
const sourceFile = program.getSourceFile(id);
|
|
676
681
|
if (sourceFile) {
|
|
677
|
-
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
682
|
+
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true, true).outputFiles) {
|
|
678
683
|
outputFiles.set(
|
|
679
684
|
resolve(publicRoot, relative(outDir, ensureAbsolute(outputFile.name, outDir))),
|
|
680
685
|
outputFile.text
|
|
@@ -847,7 +852,7 @@ export default ${libName}
|
|
|
847
852
|
entryPath: path,
|
|
848
853
|
fileName: basename(path),
|
|
849
854
|
libFolder,
|
|
850
|
-
|
|
855
|
+
rollupConfig
|
|
851
856
|
});
|
|
852
857
|
emittedFiles.delete(path);
|
|
853
858
|
rollupFiles.add(path);
|
|
@@ -861,7 +866,7 @@ export default ${libName}
|
|
|
861
866
|
entryPath: typesPath,
|
|
862
867
|
fileName: basename(typesPath),
|
|
863
868
|
libFolder,
|
|
864
|
-
|
|
869
|
+
rollupConfig
|
|
865
870
|
});
|
|
866
871
|
emittedFiles.delete(typesPath);
|
|
867
872
|
rollupFiles.add(typesPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "qmhc",
|
|
@@ -53,46 +53,43 @@
|
|
|
53
53
|
"typescript"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@microsoft/api-extractor": "^7.36.
|
|
56
|
+
"@microsoft/api-extractor": "^7.36.3",
|
|
57
57
|
"@rollup/pluginutils": "^5.0.2",
|
|
58
|
-
"@vue/language-core": "^1.8.
|
|
58
|
+
"@vue/language-core": "^1.8.8",
|
|
59
59
|
"debug": "^4.3.4",
|
|
60
60
|
"kolorist": "^1.8.0",
|
|
61
|
-
"vue-tsc": "^1.8.
|
|
61
|
+
"vue-tsc": "^1.8.8"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@commitlint/cli": "^17.6.
|
|
65
|
-
"@commitlint/config-conventional": "^17.6.6",
|
|
64
|
+
"@commitlint/cli": "^17.6.7",
|
|
66
65
|
"@types/debug": "^4.1.8",
|
|
67
66
|
"@types/minimist": "^1.2.2",
|
|
68
|
-
"@types/node": "^20.
|
|
67
|
+
"@types/node": "^20.4.5",
|
|
69
68
|
"@types/prompts": "^2.4.4",
|
|
70
69
|
"@types/semver": "^7.5.0",
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@vexip-ui/commitlint-config": "^0.1.0",
|
|
74
|
-
"@vexip-ui/eslint-config": "^0.6.3",
|
|
70
|
+
"@vexip-ui/commitlint-config": "^0.2.0",
|
|
71
|
+
"@vexip-ui/eslint-config": "^0.8.1",
|
|
75
72
|
"@vexip-ui/prettier-config": "^0.2.0",
|
|
76
73
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
77
74
|
"@vue/eslint-config-typescript": "^11.0.3",
|
|
78
75
|
"conventional-changelog-cli": "^3.0.0",
|
|
79
|
-
"eslint": "^8.
|
|
80
|
-
"execa": "^7.
|
|
76
|
+
"eslint": "^8.46.0",
|
|
77
|
+
"execa": "^7.2.0",
|
|
81
78
|
"husky": "^8.0.3",
|
|
82
79
|
"is-ci": "^3.0.1",
|
|
83
|
-
"lint-staged": "^13.2.
|
|
80
|
+
"lint-staged": "^13.2.3",
|
|
84
81
|
"minimist": "^1.2.8",
|
|
85
82
|
"pinst": "^3.0.0",
|
|
86
83
|
"prettier": "^2.8.8",
|
|
87
84
|
"pretty-quick": "^3.1.3",
|
|
88
85
|
"prompts": "^2.4.2",
|
|
89
86
|
"rimraf": "^5.0.1",
|
|
90
|
-
"semver": "^7.5.
|
|
87
|
+
"semver": "^7.5.4",
|
|
91
88
|
"tsx": "^3.12.7",
|
|
92
89
|
"typescript": "5.0.4",
|
|
93
90
|
"unbuild": "^1.2.1",
|
|
94
|
-
"vite": "^4.
|
|
95
|
-
"vitest": "^0.
|
|
91
|
+
"vite": "^4.4.7",
|
|
92
|
+
"vitest": "^0.33.0"
|
|
96
93
|
},
|
|
97
94
|
"peerDependencies": {
|
|
98
95
|
"typescript": "*",
|