vite-plugin-dts 1.4.1 → 1.6.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 +213 -208
- package/README.zh-CN.md +212 -207
- package/dist/index.d.ts +3 -3
- package/dist/index.js +132 -63
- package/dist/index.mjs +126 -70
- package/package.json +35 -34
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/plugin.ts
|
|
10
2
|
import { resolve as resolve3, dirname as dirname3, relative as relative2, basename } from "path";
|
|
11
3
|
import fs from "fs-extra";
|
|
@@ -163,20 +155,25 @@ var importTypesRE = /import\s?(?:type)?\s?\{(.+)\}\s?from\s?['"].+['"]/;
|
|
|
163
155
|
function transformDynamicImport(content) {
|
|
164
156
|
const importMap = /* @__PURE__ */ new Map();
|
|
165
157
|
content = content.replace(globalDynamicTypeRE, (str) => {
|
|
166
|
-
var _a;
|
|
167
158
|
const matchResult = str.match(dynamicTypeRE);
|
|
168
159
|
const libName = matchResult[1];
|
|
169
|
-
const importSet =
|
|
160
|
+
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
170
161
|
const usedType = matchResult[2];
|
|
171
162
|
importSet.add(usedType);
|
|
172
163
|
return usedType + matchResult[3];
|
|
173
164
|
});
|
|
174
165
|
importMap.forEach((importSet, libName) => {
|
|
175
|
-
const importReg = new RegExp(
|
|
166
|
+
const importReg = new RegExp(
|
|
167
|
+
`import\\s?(?:type)?\\s?\\{[^;\\n]+\\}\\s?from\\s?['"]${libName}['"]`,
|
|
168
|
+
"g"
|
|
169
|
+
);
|
|
176
170
|
const matchResult = content.match(importReg);
|
|
177
171
|
if (matchResult == null ? void 0 : matchResult[0]) {
|
|
178
172
|
const importedTypes = matchResult[0].match(importTypesRE)[1].trim().split(",");
|
|
179
|
-
content = content.replace(
|
|
173
|
+
content = content.replace(
|
|
174
|
+
matchResult[0],
|
|
175
|
+
`import type { ${Array.from(importSet).concat(importedTypes).join(", ")} } from '${libName}'`
|
|
176
|
+
);
|
|
180
177
|
} else {
|
|
181
178
|
content = `import type { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
182
179
|
` + content;
|
|
@@ -198,7 +195,7 @@ var staticImportRE = /(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)
|
|
|
198
195
|
var dynamicImportRE = /import\(['"]([^;\n]+?)['"]\)/;
|
|
199
196
|
var simpleStaticImportRE = /((?:import|export).+from\s?)['"](.+)['"]/;
|
|
200
197
|
var simpleDynamicImportRE = /(import\()['"](.+)['"]\)/;
|
|
201
|
-
function transformAliasImport(filePath, content, aliases) {
|
|
198
|
+
function transformAliasImport(filePath, content, aliases, exclude = []) {
|
|
202
199
|
if (!aliases.length)
|
|
203
200
|
return content;
|
|
204
201
|
return content.replace(globalImportRE, (str) => {
|
|
@@ -211,8 +208,17 @@ function transformAliasImport(filePath, content, aliases) {
|
|
|
211
208
|
if (matchResult == null ? void 0 : matchResult[1]) {
|
|
212
209
|
const matchedAlias = aliases.find((alias) => isAliasMatch(alias, matchResult[1]));
|
|
213
210
|
if (matchedAlias) {
|
|
211
|
+
if (exclude.some((e) => isRegExp(e) ? e.test(matchResult[1]) : String(e) === matchResult[1])) {
|
|
212
|
+
return str;
|
|
213
|
+
}
|
|
214
214
|
const truthPath = isAbsolute2(matchedAlias.replacement) ? normalizePath(relative(dirname2(filePath), matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
|
|
215
|
-
return str.replace(
|
|
215
|
+
return str.replace(
|
|
216
|
+
isDynamic ? simpleDynamicImportRE : simpleStaticImportRE,
|
|
217
|
+
`$1'${matchResult[1].replace(
|
|
218
|
+
matchedAlias.find,
|
|
219
|
+
(truthPath.startsWith(".") ? truthPath : `./${truthPath}`) + (typeof matchedAlias.find === "string" && matchedAlias.find.endsWith("/") ? "/" : "")
|
|
220
|
+
)}'${isDynamic ? ")" : ""}`
|
|
221
|
+
);
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
224
|
return str;
|
|
@@ -233,6 +239,7 @@ function transferSetupPosition(content) {
|
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
// src/compile.ts
|
|
242
|
+
import { createRequire } from "node:module";
|
|
236
243
|
var exportDefaultRE = /export\s+default/;
|
|
237
244
|
var exportDefaultClassRE = /(?:(?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
|
|
238
245
|
var noScriptContent = "import { defineComponent } from 'vue'\nexport default defineComponent({})";
|
|
@@ -240,20 +247,21 @@ var index = 1;
|
|
|
240
247
|
var compileRoot = null;
|
|
241
248
|
var compiler;
|
|
242
249
|
var vue;
|
|
250
|
+
var _require = createRequire(import.meta.url);
|
|
243
251
|
function requireCompiler() {
|
|
244
252
|
if (!compiler) {
|
|
245
253
|
if (compileRoot) {
|
|
246
254
|
try {
|
|
247
|
-
compiler =
|
|
255
|
+
compiler = _require(_require.resolve("vue/compiler-sfc", { paths: [compileRoot] }));
|
|
248
256
|
} catch (e) {
|
|
249
257
|
}
|
|
250
258
|
}
|
|
251
259
|
if (!compiler) {
|
|
252
260
|
try {
|
|
253
|
-
compiler =
|
|
261
|
+
compiler = _require("vue/compiler-sfc");
|
|
254
262
|
} catch (e) {
|
|
255
263
|
try {
|
|
256
|
-
compiler =
|
|
264
|
+
compiler = _require("@vue/compiler-sfc");
|
|
257
265
|
} catch (e2) {
|
|
258
266
|
throw new Error("@vue/compiler-sfc is not present in the dependency tree.\n");
|
|
259
267
|
}
|
|
@@ -266,13 +274,13 @@ function isVue3() {
|
|
|
266
274
|
if (!vue) {
|
|
267
275
|
if (compileRoot) {
|
|
268
276
|
try {
|
|
269
|
-
vue =
|
|
277
|
+
vue = _require(_require.resolve("vue", { paths: [compileRoot] }));
|
|
270
278
|
} catch (e) {
|
|
271
279
|
}
|
|
272
280
|
}
|
|
273
281
|
if (!vue) {
|
|
274
282
|
try {
|
|
275
|
-
vue =
|
|
283
|
+
vue = _require("vue");
|
|
276
284
|
} catch (e) {
|
|
277
285
|
throw new Error("vue is not present in the dependency tree.\n");
|
|
278
286
|
}
|
|
@@ -308,7 +316,7 @@ function compileVueCode(code) {
|
|
|
308
316
|
id: `${index++}`
|
|
309
317
|
});
|
|
310
318
|
const classMatch = compiled.content.match(exportDefaultClassRE);
|
|
311
|
-
const plugins = scriptSetup.lang === "ts" ? ["typescript"] : void 0;
|
|
319
|
+
const plugins = scriptSetup.lang === "ts" ? ["typescript", "decorators-legacy"] : void 0;
|
|
312
320
|
if (classMatch) {
|
|
313
321
|
content = compiled.content.replace(exportDefaultClassRE, "\nclass $1") + `
|
|
314
322
|
const _sfc_main = ${classMatch[1]}`;
|
|
@@ -319,10 +327,18 @@ const _sfc_main = ${classMatch[1]}`;
|
|
|
319
327
|
content = rewriteDefault(compiled.content, "_sfc_main", plugins);
|
|
320
328
|
}
|
|
321
329
|
content = transferSetupPosition(content);
|
|
330
|
+
content = content.replace(/(const __returned__\s?=\s?\{[\s\S]+?)(props)(\s?\})/, "$1props: props as any$3").replace(
|
|
331
|
+
/(const __returned__\s?=\s?\{[\s\S]+?)(props,)([\s\S]+?)/,
|
|
332
|
+
"$1props: props as any,$3"
|
|
333
|
+
);
|
|
322
334
|
content += "\nexport default _sfc_main\n";
|
|
323
335
|
ext = scriptSetup.lang || "js";
|
|
324
336
|
} else if (script && script.content) {
|
|
325
|
-
content = rewriteDefault(
|
|
337
|
+
content = rewriteDefault(
|
|
338
|
+
script.content,
|
|
339
|
+
"_sfc_main",
|
|
340
|
+
script.lang === "ts" ? ["typescript"] : void 0
|
|
341
|
+
);
|
|
326
342
|
content += "\nexport default _sfc_main\n";
|
|
327
343
|
ext = script.lang || "js";
|
|
328
344
|
}
|
|
@@ -414,7 +430,12 @@ function rollupDeclarationFiles({
|
|
|
414
430
|
extractorConfig
|
|
415
431
|
});
|
|
416
432
|
collector.analyze();
|
|
417
|
-
DtsRollupGenerator.writeTypingsFile(
|
|
433
|
+
DtsRollupGenerator.writeTypingsFile(
|
|
434
|
+
collector,
|
|
435
|
+
extractorConfig.publicTrimmedFilePath,
|
|
436
|
+
DtsRollupKind.PublicRelease,
|
|
437
|
+
extractorConfig.newlineKind
|
|
438
|
+
);
|
|
418
439
|
}
|
|
419
440
|
|
|
420
441
|
// src/plugin.ts
|
|
@@ -433,7 +454,6 @@ var noop = () => {
|
|
|
433
454
|
var logPrefix = chalk.cyan("[vite:dts]");
|
|
434
455
|
var bundleDebug = debug("vite-plugin-dts:bundle");
|
|
435
456
|
function dtsPlugin(options = {}) {
|
|
436
|
-
var _a, _b;
|
|
437
457
|
const {
|
|
438
458
|
tsConfigFilePath = "tsconfig.json",
|
|
439
459
|
aliasesExclude = [],
|
|
@@ -450,9 +470,9 @@ function dtsPlugin(options = {}) {
|
|
|
450
470
|
beforeWriteFile = noop,
|
|
451
471
|
afterBuild = noop
|
|
452
472
|
} = options;
|
|
453
|
-
const compilerOptions =
|
|
473
|
+
const compilerOptions = options.compilerOptions ?? {};
|
|
454
474
|
let root;
|
|
455
|
-
let entryRoot =
|
|
475
|
+
let entryRoot = options.entryRoot ?? "";
|
|
456
476
|
let libName;
|
|
457
477
|
let indexName;
|
|
458
478
|
let aliases;
|
|
@@ -470,10 +490,10 @@ function dtsPlugin(options = {}) {
|
|
|
470
490
|
apply: "build",
|
|
471
491
|
enforce: "pre",
|
|
472
492
|
config(config) {
|
|
473
|
-
var
|
|
493
|
+
var _a;
|
|
474
494
|
if (isBundle)
|
|
475
495
|
return;
|
|
476
|
-
const aliasOptions = (
|
|
496
|
+
const aliasOptions = ((_a = config == null ? void 0 : config.resolve) == null ? void 0 : _a.alias) ?? [];
|
|
477
497
|
if (isNativeObj(aliasOptions)) {
|
|
478
498
|
aliases = Object.entries(aliasOptions).map(([key, value]) => {
|
|
479
499
|
return { find: key, replacement: value };
|
|
@@ -482,38 +502,53 @@ function dtsPlugin(options = {}) {
|
|
|
482
502
|
aliases = ensureArray(aliasOptions);
|
|
483
503
|
}
|
|
484
504
|
if (aliasesExclude.length > 0) {
|
|
485
|
-
aliases = aliases.filter(
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
505
|
+
aliases = aliases.filter(
|
|
506
|
+
({ find }) => !aliasesExclude.some(
|
|
507
|
+
(alias) => {
|
|
508
|
+
var _a2;
|
|
509
|
+
return alias && (isRegExp(find) ? find.toString() === alias.toString() : isRegExp(alias) ? (_a2 = find.match(alias)) == null ? void 0 : _a2[0] : find === alias);
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
);
|
|
489
513
|
}
|
|
490
514
|
},
|
|
491
515
|
configResolved(config) {
|
|
492
|
-
var _a2, _b2, _c;
|
|
493
516
|
if (isBundle)
|
|
494
517
|
return;
|
|
495
518
|
logger = config.logger;
|
|
496
519
|
if (!config.build.lib) {
|
|
497
|
-
logger.warn(
|
|
498
|
-
|
|
499
|
-
`
|
|
520
|
+
logger.warn(
|
|
521
|
+
chalk.yellow(
|
|
522
|
+
`
|
|
523
|
+
${chalk.cyan(
|
|
524
|
+
"[vite:dts]"
|
|
525
|
+
)} You building not a library that may not need to generate declaration files.
|
|
526
|
+
`
|
|
527
|
+
)
|
|
528
|
+
);
|
|
500
529
|
libName = "_default";
|
|
501
530
|
indexName = defaultIndex;
|
|
502
531
|
} else {
|
|
503
|
-
const filename =
|
|
532
|
+
const filename = config.build.lib.fileName ?? defaultIndex;
|
|
504
533
|
libName = config.build.lib.name || "_default";
|
|
505
534
|
indexName = typeof filename === "string" ? filename : filename("es");
|
|
506
535
|
if (!dtsRE2.test(indexName)) {
|
|
507
536
|
indexName = `${tjsRE.test(indexName) ? indexName.replace(tjsRE, "") : indexName}.d.ts`;
|
|
508
537
|
}
|
|
509
538
|
}
|
|
510
|
-
root = ensureAbsolute(
|
|
539
|
+
root = ensureAbsolute(options.root ?? "", config.root);
|
|
511
540
|
tsConfigPath = ensureAbsolute(tsConfigFilePath, root);
|
|
512
541
|
outputDirs = options.outputDir ? ensureArray(options.outputDir).map((d) => ensureAbsolute(d, root)) : [ensureAbsolute(config.build.outDir, root)];
|
|
513
|
-
if (!outputDirs) {
|
|
514
|
-
logger.error(
|
|
515
|
-
|
|
516
|
-
`
|
|
542
|
+
if (!outputDirs[0]) {
|
|
543
|
+
logger.error(
|
|
544
|
+
chalk.red(
|
|
545
|
+
`
|
|
546
|
+
${chalk.cyan(
|
|
547
|
+
"[vite:dts]"
|
|
548
|
+
)} Can not resolve declaration directory, please check your vite config and plugin options.
|
|
549
|
+
`
|
|
550
|
+
)
|
|
551
|
+
);
|
|
517
552
|
return;
|
|
518
553
|
}
|
|
519
554
|
setCompileRoot(root);
|
|
@@ -531,7 +566,7 @@ ${chalk.cyan("[vite:dts]")} Can not resolve declaration directory, please check
|
|
|
531
566
|
tsConfigFilePath: tsConfigPath,
|
|
532
567
|
skipAddingFilesFromTsConfig: true
|
|
533
568
|
});
|
|
534
|
-
allowJs =
|
|
569
|
+
allowJs = project.getCompilerOptions().allowJs ?? false;
|
|
535
570
|
},
|
|
536
571
|
buildStart(inputOptions) {
|
|
537
572
|
if (!isBundle && (insertTypesEntry || rollupTypes)) {
|
|
@@ -564,7 +599,6 @@ ${chalk.cyan("[vite:dts]")} Can not resolve declaration directory, please check
|
|
|
564
599
|
}
|
|
565
600
|
},
|
|
566
601
|
async closeBundle() {
|
|
567
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
568
602
|
if (!outputDirs || !project || isBundle)
|
|
569
603
|
return;
|
|
570
604
|
logger.info(chalk.green(`
|
|
@@ -573,11 +607,11 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
573
607
|
isBundle = true;
|
|
574
608
|
sourceDtsFiles.clear();
|
|
575
609
|
const startTime = Date.now();
|
|
576
|
-
const tsConfig =
|
|
610
|
+
const tsConfig = readConfigFile(tsConfigPath, project.getFileSystem().readFileSync).config ?? {};
|
|
577
611
|
const parentTsConfigPath = tsConfig.extends && ensureAbsolute(tsConfig.extends, root);
|
|
578
612
|
const parentTsConfig = parentTsConfigPath ? readConfigFile(parentTsConfigPath, project.getFileSystem().readFileSync).config : {};
|
|
579
|
-
const include =
|
|
580
|
-
const exclude =
|
|
613
|
+
const include = options.include ?? tsConfig.include ?? parentTsConfig.include ?? "**/*";
|
|
614
|
+
const exclude = options.exclude ?? tsConfig.exclude ?? parentTsConfig.exclude ?? "node_modules/**";
|
|
581
615
|
bundleDebug("read config");
|
|
582
616
|
const includedFileSet = /* @__PURE__ */ new Set();
|
|
583
617
|
if (include && include.length) {
|
|
@@ -599,13 +633,18 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
599
633
|
});
|
|
600
634
|
if (hasJsVue) {
|
|
601
635
|
if (!allowJs) {
|
|
602
|
-
logger.warn(
|
|
636
|
+
logger.warn(
|
|
637
|
+
chalk.yellow(
|
|
638
|
+
`${chalk.cyan(
|
|
639
|
+
"[vite:dts]"
|
|
640
|
+
)} Some js files are referenced, but you may not enable the 'allowJs' option.`
|
|
641
|
+
)
|
|
642
|
+
);
|
|
603
643
|
}
|
|
604
644
|
project.compilerOptions.set({ allowJs: true });
|
|
605
645
|
}
|
|
606
646
|
bundleDebug("collect files");
|
|
607
647
|
}
|
|
608
|
-
project.resolveSourceFileDependencies();
|
|
609
648
|
bundleDebug("resolve");
|
|
610
649
|
if (!skipDiagnostics) {
|
|
611
650
|
const diagnostics = project.getPreEmitDiagnostics();
|
|
@@ -623,10 +662,12 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
623
662
|
content: sourceFile.getFullText()
|
|
624
663
|
}));
|
|
625
664
|
const service = project.getLanguageService();
|
|
626
|
-
const outputFiles = project.getSourceFiles().map(
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
665
|
+
const outputFiles = project.getSourceFiles().map(
|
|
666
|
+
(sourceFile) => service.getEmitOutput(sourceFile, true).getOutputFiles().map((outputFile) => ({
|
|
667
|
+
path: normalizePath2(resolve3(root, outputFile.compilerObject.name)),
|
|
668
|
+
content: outputFile.getText()
|
|
669
|
+
}))
|
|
670
|
+
).flat().concat(dtsOutputFiles);
|
|
630
671
|
bundleDebug("emit");
|
|
631
672
|
if (!entryRoot) {
|
|
632
673
|
entryRoot = queryPublicPath(outputFiles.map((file) => file.path));
|
|
@@ -635,7 +676,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
635
676
|
const wroteFiles = /* @__PURE__ */ new Set();
|
|
636
677
|
const outputDir = outputDirs[0];
|
|
637
678
|
await runParallel(os.cpus().length, outputFiles, async (outputFile) => {
|
|
638
|
-
var _a3, _b3;
|
|
639
679
|
let filePath = outputFile.path;
|
|
640
680
|
let content = outputFile.content;
|
|
641
681
|
const isMapFile = filePath.endsWith(".map");
|
|
@@ -644,19 +684,28 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
644
684
|
}
|
|
645
685
|
if (!isMapFile && content && content !== noneExport) {
|
|
646
686
|
content = clearPureImport ? removePureImport(content) : content;
|
|
647
|
-
content = transformAliasImport(filePath, content, aliases);
|
|
687
|
+
content = transformAliasImport(filePath, content, aliases, aliasesExclude);
|
|
648
688
|
content = staticImport || rollupTypes ? transformDynamicImport(content) : content;
|
|
649
689
|
}
|
|
650
|
-
filePath = resolve3(
|
|
690
|
+
filePath = resolve3(
|
|
691
|
+
outputDir,
|
|
692
|
+
relative2(entryRoot, cleanVueFileName ? filePath.replace(".vue.d.ts", ".d.ts") : filePath)
|
|
693
|
+
);
|
|
651
694
|
if (typeof beforeWriteFile === "function") {
|
|
652
695
|
const result = beforeWriteFile(filePath, content);
|
|
696
|
+
if (result === false)
|
|
697
|
+
return;
|
|
653
698
|
if (result && isNativeObj(result)) {
|
|
654
|
-
filePath =
|
|
655
|
-
content =
|
|
699
|
+
filePath = result.filePath ?? filePath;
|
|
700
|
+
content = result.content ?? content;
|
|
656
701
|
}
|
|
657
702
|
}
|
|
658
703
|
await fs.mkdir(dirname3(filePath), { recursive: true });
|
|
659
|
-
await fs.writeFile(
|
|
704
|
+
await fs.writeFile(
|
|
705
|
+
filePath,
|
|
706
|
+
cleanVueFileName ? content.replace(/['"](.+)\.vue['"]/g, '"$1"') : content,
|
|
707
|
+
"utf-8"
|
|
708
|
+
);
|
|
660
709
|
wroteFiles.add(normalizePath2(filePath));
|
|
661
710
|
});
|
|
662
711
|
bundleDebug("output");
|
|
@@ -681,15 +730,18 @@ export default ${libName}
|
|
|
681
730
|
`;
|
|
682
731
|
}
|
|
683
732
|
}
|
|
733
|
+
let result;
|
|
684
734
|
if (typeof beforeWriteFile === "function") {
|
|
685
|
-
|
|
735
|
+
result = beforeWriteFile(typesPath, content);
|
|
686
736
|
if (result && isNativeObj(result)) {
|
|
687
|
-
typesPath =
|
|
688
|
-
content =
|
|
737
|
+
typesPath = result.filePath ?? typesPath;
|
|
738
|
+
content = result.content ?? content;
|
|
689
739
|
}
|
|
690
740
|
}
|
|
691
|
-
|
|
692
|
-
|
|
741
|
+
if (result !== false) {
|
|
742
|
+
await fs.writeFile(typesPath, content, "utf-8");
|
|
743
|
+
wroteFiles.add(normalizePath2(typesPath));
|
|
744
|
+
}
|
|
693
745
|
}
|
|
694
746
|
bundleDebug("insert index");
|
|
695
747
|
if (rollupTypes) {
|
|
@@ -723,11 +775,13 @@ export default ${libName}
|
|
|
723
775
|
await runParallel(os.cpus().length, Array.from(wroteFiles), async (wroteFile) => {
|
|
724
776
|
const relativePath = relative2(outputDir, wroteFile);
|
|
725
777
|
const content = await fs.readFile(wroteFile, "utf-8");
|
|
726
|
-
await Promise.all(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
778
|
+
await Promise.all(
|
|
779
|
+
dirs.map(async (dir) => {
|
|
780
|
+
const filePath = resolve3(dir, relativePath);
|
|
781
|
+
await fs.mkdir(dirname3(filePath), { recursive: true });
|
|
782
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
783
|
+
})
|
|
784
|
+
);
|
|
731
785
|
});
|
|
732
786
|
}
|
|
733
787
|
if (typeof afterBuild === "function") {
|
|
@@ -735,8 +789,10 @@ export default ${libName}
|
|
|
735
789
|
isPromise(result) && await result;
|
|
736
790
|
}
|
|
737
791
|
bundleDebug("finish");
|
|
738
|
-
logger.info(
|
|
739
|
-
|
|
792
|
+
logger.info(
|
|
793
|
+
chalk.green(`${logPrefix} Declaration files built in ${Date.now() - startTime}ms.
|
|
794
|
+
`)
|
|
795
|
+
);
|
|
740
796
|
}
|
|
741
797
|
};
|
|
742
798
|
}
|
package/package.json
CHANGED
|
@@ -6,51 +6,52 @@
|
|
|
6
6
|
"url": "https://github.com/qmhc/vite-plugin-dts/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@microsoft/api-extractor": "^7.
|
|
10
|
-
"@rushstack/node-core-library": "^3.
|
|
9
|
+
"@microsoft/api-extractor": "^7.31.2",
|
|
10
|
+
"@rushstack/node-core-library": "^3.52.0",
|
|
11
11
|
"chalk": "^4.1.2",
|
|
12
12
|
"debug": "^4.3.4",
|
|
13
|
-
"fast-glob": "^3.2.
|
|
14
|
-
"fs-extra": "^10.0
|
|
15
|
-
"ts-morph": "^
|
|
13
|
+
"fast-glob": "^3.2.12",
|
|
14
|
+
"fs-extra": "^10.1.0",
|
|
15
|
+
"ts-morph": "^16.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@commitlint/cli": "^
|
|
19
|
-
"@commitlint/config-conventional": "^
|
|
18
|
+
"@commitlint/cli": "^17.1.2",
|
|
19
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
20
20
|
"@types/debug": "^4.1.7",
|
|
21
21
|
"@types/fs-extra": "^9.0.13",
|
|
22
|
-
"@types/jest": "^
|
|
23
|
-
"@
|
|
24
|
-
"@typescript-eslint/
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@vue/eslint-config-
|
|
28
|
-
"
|
|
22
|
+
"@types/jest": "^29.0.3",
|
|
23
|
+
"@types/node": "^18.7.23",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
25
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
26
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
27
|
+
"@vue/eslint-config-standard": "^8.0.1",
|
|
28
|
+
"@vue/eslint-config-typescript": "^11.0.2",
|
|
29
|
+
"commitizen": "^4.2.5",
|
|
29
30
|
"conventional-changelog-cli": "^2.2.2",
|
|
30
31
|
"cross-env": "^7.0.3",
|
|
31
|
-
"cz-customizable": "^
|
|
32
|
+
"cz-customizable": "^7.0.0",
|
|
32
33
|
"enquirer": "^2.3.6",
|
|
33
|
-
"eslint": "^8.
|
|
34
|
-
"eslint-plugin-import": "^2.
|
|
34
|
+
"eslint": "^8.24.0",
|
|
35
|
+
"eslint-plugin-import": "^2.26.0",
|
|
35
36
|
"eslint-plugin-node": "^11.1.0",
|
|
36
|
-
"eslint-plugin-promise": "^6.0.
|
|
37
|
-
"eslint-plugin-vue": "^
|
|
37
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
38
|
+
"eslint-plugin-vue": "^9.5.1",
|
|
38
39
|
"execa": "^5.1.1",
|
|
39
|
-
"husky": "^
|
|
40
|
+
"husky": "^8.0.1",
|
|
40
41
|
"is-ci": "^3.0.1",
|
|
41
|
-
"jest": "^
|
|
42
|
-
"lint-staged": "^
|
|
43
|
-
"minimist": "^1.2.
|
|
42
|
+
"jest": "^29.0.3",
|
|
43
|
+
"lint-staged": "^13.0.3",
|
|
44
|
+
"minimist": "^1.2.6",
|
|
44
45
|
"pinst": "^3.0.0",
|
|
45
|
-
"prettier": "^2.
|
|
46
|
+
"prettier": "^2.7.1",
|
|
46
47
|
"pretty-quick": "^3.1.3",
|
|
47
48
|
"rimraf": "^3.0.2",
|
|
48
|
-
"semver": "^7.3.
|
|
49
|
-
"ts-jest": "^
|
|
50
|
-
"tsup": "^
|
|
51
|
-
"typescript": "4.
|
|
52
|
-
"vite": "^
|
|
53
|
-
"vue": "3.2.
|
|
49
|
+
"semver": "^7.3.7",
|
|
50
|
+
"ts-jest": "^29.0.2",
|
|
51
|
+
"tsup": "^6.2.3",
|
|
52
|
+
"typescript": "4.7.4",
|
|
53
|
+
"vite": "^3.1.3",
|
|
54
|
+
"vue": "3.2.40"
|
|
54
55
|
},
|
|
55
56
|
"engines": {
|
|
56
57
|
"node": ">=12.0.0"
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"module": "dist/index.mjs",
|
|
71
72
|
"name": "vite-plugin-dts",
|
|
72
73
|
"peerDependencies": {
|
|
73
|
-
"vite": ">=
|
|
74
|
+
"vite": ">=3.0.0"
|
|
74
75
|
},
|
|
75
76
|
"repository": {
|
|
76
77
|
"type": "git",
|
|
@@ -85,13 +86,13 @@
|
|
|
85
86
|
"lint:example": "eslint --fix --ext .js,.jsx,.ts,.tsx,.vue example/{src,components}/**",
|
|
86
87
|
"_postinstall": "is-ci || husky install",
|
|
87
88
|
"postpublish": "pinst --enable",
|
|
88
|
-
"precommit": "lint-staged -c ./.husky/.lintstagedrc",
|
|
89
|
+
"precommit": "lint-staged -c ./.husky/.lintstagedrc -q",
|
|
89
90
|
"prepublishOnly": "pinst --disable",
|
|
90
91
|
"prettier": "pretty-quick --staged",
|
|
91
92
|
"release": "node scripts/release.js",
|
|
92
93
|
"test": "jest --runInBand",
|
|
93
|
-
"test:e2e": "
|
|
94
|
+
"test:e2e": "pnpm -C example build"
|
|
94
95
|
},
|
|
95
96
|
"types": "dist/index.d.ts",
|
|
96
|
-
"version": "1.
|
|
97
|
+
"version": "1.6.0"
|
|
97
98
|
}
|