vite-plugin-dts 3.7.2 → 3.8.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 +393 -393
- package/README.zh-CN.md +393 -393
- package/dist/index.cjs +183 -112
- package/dist/index.mjs +182 -112
- package/package.json +22 -21
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { createProgram } from 'vue-tsc';
|
|
|
16
16
|
import debug from 'debug';
|
|
17
17
|
import { cyan, yellow, green } from 'kolorist';
|
|
18
18
|
import { ExtractorConfig, Extractor } from '@microsoft/api-extractor';
|
|
19
|
+
import MagicString from 'magic-string';
|
|
19
20
|
|
|
20
21
|
const windowsSlashRE = /\\+/g;
|
|
21
22
|
function slash(p) {
|
|
@@ -36,7 +37,7 @@ function isRegExp(value) {
|
|
|
36
37
|
function isPromise(value) {
|
|
37
38
|
return !!value && (typeof value === "function" || typeof value === "object") && typeof value.then === "function";
|
|
38
39
|
}
|
|
39
|
-
async function
|
|
40
|
+
async function unwrapPromise(maybePromise) {
|
|
40
41
|
return isPromise(maybePromise) ? await maybePromise : maybePromise;
|
|
41
42
|
}
|
|
42
43
|
function ensureAbsolute(path, root) {
|
|
@@ -413,46 +414,13 @@ function normalizeGlob(path) {
|
|
|
413
414
|
}
|
|
414
415
|
return path;
|
|
415
416
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const importMap = /* @__PURE__ */ new Map();
|
|
421
|
-
const defaultMap = /* @__PURE__ */ new Map();
|
|
422
|
-
let defaultCount = 1;
|
|
423
|
-
content = content.replace(globalDynamicTypeRE, (str) => {
|
|
424
|
-
const matchResult = str.match(dynamicTypeRE);
|
|
425
|
-
const libName = matchResult[1];
|
|
426
|
-
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
427
|
-
let usedType = matchResult[2];
|
|
428
|
-
if (usedType === "default") {
|
|
429
|
-
usedType = defaultMap.get(libName) ?? defaultMap.set(libName, `__DTS_${defaultCount++}__`).get(libName);
|
|
430
|
-
importSet.add(`default as ${usedType}`);
|
|
431
|
-
} else {
|
|
432
|
-
importSet.add(usedType);
|
|
433
|
-
}
|
|
434
|
-
return usedType + matchResult[3];
|
|
435
|
-
});
|
|
436
|
-
importMap.forEach((importSet, libName) => {
|
|
437
|
-
const importReg = new RegExp(
|
|
438
|
-
`import\\s?(?:type)?\\s?\\{[^;\\n]+\\}\\s?from\\s?['"]${libName}['"]`,
|
|
439
|
-
"g"
|
|
440
|
-
);
|
|
441
|
-
const matchResult = content.match(importReg);
|
|
442
|
-
if (matchResult?.[0]) {
|
|
443
|
-
matchResult[0].match(importTypesRE)[1].trim().split(",").forEach((type) => {
|
|
444
|
-
type && importSet.add(type.trim());
|
|
445
|
-
});
|
|
446
|
-
content = content.replace(
|
|
447
|
-
matchResult[0],
|
|
448
|
-
`import { ${Array.from(importSet).join(", ")} } from '${libName}'`
|
|
449
|
-
);
|
|
450
|
-
} else {
|
|
451
|
-
content = `import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
452
|
-
` + content;
|
|
417
|
+
function walkSourceFile(sourceFile, callback) {
|
|
418
|
+
function walkNode(node, parent, callback2) {
|
|
419
|
+
if (callback2(node, parent) !== false) {
|
|
420
|
+
node.forEachChild((child) => walkNode(child, node, callback2));
|
|
453
421
|
}
|
|
454
|
-
}
|
|
455
|
-
|
|
422
|
+
}
|
|
423
|
+
sourceFile.forEachChild((child) => walkNode(child, sourceFile, callback));
|
|
456
424
|
}
|
|
457
425
|
function isAliasMatch(alias, importer) {
|
|
458
426
|
if (isRegExp(alias.find))
|
|
@@ -463,54 +431,132 @@ function isAliasMatch(alias, importer) {
|
|
|
463
431
|
return true;
|
|
464
432
|
return importer.indexOf(alias.find) === 0 && (alias.find.endsWith("/") || importer.substring(alias.find.length)[0] === "/");
|
|
465
433
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
let matchResult = str.match(staticImportRE);
|
|
479
|
-
let isDynamic = false;
|
|
480
|
-
if (!matchResult) {
|
|
481
|
-
matchResult = str.match(dynamicImportRE);
|
|
482
|
-
isDynamic = true;
|
|
434
|
+
function transformAlias(importer, dir, aliases, aliasesExclude) {
|
|
435
|
+
if (aliases.length && !aliasesExclude.some((e) => isRegExp(e) ? e.test(importer) : String(e) === importer)) {
|
|
436
|
+
const matchedAlias = aliases.find((alias) => isAliasMatch(alias, importer));
|
|
437
|
+
if (matchedAlias) {
|
|
438
|
+
const replacement = isAbsolute(matchedAlias.replacement) ? normalizePath(relative(dir, matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
|
|
439
|
+
const endsWithSlash = typeof matchedAlias.find === "string" ? matchedAlias.find.endsWith("/") : importer.match(matchedAlias.find)[0].endsWith("/");
|
|
440
|
+
const truthPath = importer.replace(
|
|
441
|
+
matchedAlias.find,
|
|
442
|
+
replacement + (endsWithSlash ? "/" : "")
|
|
443
|
+
);
|
|
444
|
+
const normalizedPath = normalizePath(relative(dir, resolve$1(dir, truthPath)));
|
|
445
|
+
return normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
|
|
483
446
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
447
|
+
}
|
|
448
|
+
return importer;
|
|
449
|
+
}
|
|
450
|
+
function transformCode(options) {
|
|
451
|
+
const s = new MagicString(options.content);
|
|
452
|
+
const ast = ts.createSourceFile("a.ts", options.content, ts.ScriptTarget.Latest);
|
|
453
|
+
const dir = dirname(options.filePath);
|
|
454
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
455
|
+
const usedDefault = /* @__PURE__ */ new Map();
|
|
456
|
+
const declareModules = [];
|
|
457
|
+
let indexCount = 0;
|
|
458
|
+
walkSourceFile(ast, (node, parent) => {
|
|
459
|
+
if (ts.isImportDeclaration(node)) {
|
|
460
|
+
if (!node.importClause) {
|
|
461
|
+
options.clearPureImport && s.remove(node.pos, node.end);
|
|
462
|
+
} else if (ts.isStringLiteral(node.moduleSpecifier) && (node.importClause.name || node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings))) {
|
|
463
|
+
const libName = transformAlias(
|
|
464
|
+
node.moduleSpecifier.text,
|
|
465
|
+
dir,
|
|
466
|
+
options.aliases,
|
|
467
|
+
options.aliasesExclude
|
|
501
468
|
);
|
|
469
|
+
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
470
|
+
if (node.importClause.name && !usedDefault.has(libName)) {
|
|
471
|
+
const usedType = node.importClause.name.escapedText;
|
|
472
|
+
usedDefault.set(libName, usedType);
|
|
473
|
+
importSet.add(`default as ${usedType}`);
|
|
474
|
+
}
|
|
475
|
+
if (node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {
|
|
476
|
+
node.importClause.namedBindings.elements.forEach((element) => {
|
|
477
|
+
importSet.add(element.name.escapedText);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
s.remove(node.pos, node.end);
|
|
502
481
|
}
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
if (ts.isImportTypeNode(node) && node.qualifier && ts.isLiteralTypeNode(node.argument) && ts.isIdentifier(node.qualifier) && ts.isStringLiteral(node.argument.literal)) {
|
|
485
|
+
const libName = transformAlias(
|
|
486
|
+
node.argument.literal.text,
|
|
487
|
+
dir,
|
|
488
|
+
options.aliases,
|
|
489
|
+
options.aliasesExclude
|
|
490
|
+
);
|
|
491
|
+
if (!options.staticImport) {
|
|
492
|
+
s.update(node.argument.literal.pos, node.argument.literal.end, `'${libName}'`);
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
|
|
496
|
+
let usedType = node.qualifier.escapedText;
|
|
497
|
+
if (usedType === "default") {
|
|
498
|
+
usedType = usedDefault.get(libName) ?? usedDefault.set(libName, `__DTS_DEFAULT_${indexCount++}__`).get(libName);
|
|
499
|
+
importSet.add(`default as ${usedType}`);
|
|
500
|
+
s.update(node.qualifier.pos, node.qualifier.end, usedType);
|
|
501
|
+
} else {
|
|
502
|
+
importSet.add(usedType);
|
|
503
|
+
}
|
|
504
|
+
if (ts.isImportTypeNode(parent) && parent.typeArguments && parent.typeArguments[0] === node) {
|
|
505
|
+
s.remove(node.pos, node.argument.end + 2);
|
|
506
|
+
} else {
|
|
507
|
+
s.update(node.pos, node.argument.end + 2, " ");
|
|
508
|
+
}
|
|
509
|
+
return !!node.typeArguments;
|
|
510
|
+
}
|
|
511
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && ts.isStringLiteral(node.arguments[0])) {
|
|
512
|
+
const libName = transformAlias(
|
|
513
|
+
node.arguments[0].text,
|
|
514
|
+
dir,
|
|
515
|
+
options.aliases,
|
|
516
|
+
options.aliasesExclude
|
|
517
|
+
);
|
|
518
|
+
s.update(node.arguments[0].pos, node.arguments[0].end, `'${libName}'`);
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
522
|
+
const libName = transformAlias(
|
|
523
|
+
node.moduleSpecifier.text,
|
|
524
|
+
dir,
|
|
525
|
+
options.aliases,
|
|
526
|
+
options.aliasesExclude
|
|
527
|
+
);
|
|
528
|
+
s.update(node.moduleSpecifier.pos, node.moduleSpecifier.end, ` '${libName}'`);
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
if (ts.isModuleDeclaration(node)) {
|
|
532
|
+
declareModules.push(s.slice(node.pos, node.end + 1));
|
|
503
533
|
}
|
|
504
|
-
return str;
|
|
505
534
|
});
|
|
535
|
+
importMap.forEach((importSet, libName) => {
|
|
536
|
+
s.prepend(`import { ${Array.from(importSet).join(", ")} } from '${libName}';
|
|
537
|
+
`);
|
|
538
|
+
});
|
|
539
|
+
return {
|
|
540
|
+
content: s.toString(),
|
|
541
|
+
declareModules
|
|
542
|
+
};
|
|
506
543
|
}
|
|
507
|
-
const pureImportRE = /import\s?['"][^;\n]+?['"];?\n?/g;
|
|
508
|
-
function removePureImport(content) {
|
|
509
|
-
return content.replace(pureImportRE, "");
|
|
510
|
-
}
|
|
511
|
-
const asDefaultRE = /export\s*\{.*\w+\s*\bas\s+default\b.*\}\s*from\s*['"].+['"]/;
|
|
512
544
|
function hasExportDefault(content) {
|
|
513
|
-
|
|
545
|
+
const ast = ts.createSourceFile("a.ts", content, ts.ScriptTarget.Latest);
|
|
546
|
+
let has = false;
|
|
547
|
+
walkSourceFile(ast, (node) => {
|
|
548
|
+
if (ts.isExportAssignment(node)) {
|
|
549
|
+
has = true;
|
|
550
|
+
} else if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
551
|
+
for (const element of node.exportClause.elements) {
|
|
552
|
+
if (element.name.escapedText === "default") {
|
|
553
|
+
has = true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return false;
|
|
558
|
+
});
|
|
559
|
+
return has;
|
|
514
560
|
}
|
|
515
561
|
|
|
516
562
|
const jsRE = /\.(m|c)?jsx?$/;
|
|
@@ -521,7 +567,8 @@ const mtjsRE = /\.m(t|j)sx?$/;
|
|
|
521
567
|
const ctjsRE = /\.c(t|j)sx?$/;
|
|
522
568
|
const fullRelativeRE = /^\.\.?\//;
|
|
523
569
|
const defaultIndex = "index.d.ts";
|
|
524
|
-
const
|
|
570
|
+
const pluginName = "vite:dts";
|
|
571
|
+
const logPrefix = cyan(`[${pluginName}]`);
|
|
525
572
|
const bundleDebug = debug("vite-plugin-dts:bundle");
|
|
526
573
|
const fixedCompilerOptions = {
|
|
527
574
|
noEmit: false,
|
|
@@ -537,6 +584,7 @@ const fixedCompilerOptions = {
|
|
|
537
584
|
const noop = () => {
|
|
538
585
|
};
|
|
539
586
|
const extPrefix = (file) => mtjsRE.test(file) ? "m" : ctjsRE.test(file) ? "c" : "";
|
|
587
|
+
const tsToDts = (path) => `${path.replace(tsRE, "")}.d.ts`;
|
|
540
588
|
const regexpSymbolRE = /([$.\\+?()[\]!<=|{}^,])/g;
|
|
541
589
|
const asteriskRE = /[*]+/g;
|
|
542
590
|
function dtsPlugin(options = {}) {
|
|
@@ -587,8 +635,11 @@ function dtsPlugin(options = {}) {
|
|
|
587
635
|
const outputFiles = /* @__PURE__ */ new Map();
|
|
588
636
|
const rollupConfig = { ...options.rollupConfig || {} };
|
|
589
637
|
rollupConfig.bundledPackages = rollupConfig.bundledPackages || options.bundledPackages || [];
|
|
638
|
+
const cleanPath = (path) => {
|
|
639
|
+
return cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path;
|
|
640
|
+
};
|
|
590
641
|
return {
|
|
591
|
-
name:
|
|
642
|
+
name: pluginName,
|
|
592
643
|
apply: "build",
|
|
593
644
|
enforce: "pre",
|
|
594
645
|
config(config) {
|
|
@@ -743,12 +794,16 @@ ${logPrefix} ${yellow(
|
|
|
743
794
|
publicRoot = normalizePath(publicRoot);
|
|
744
795
|
entryRoot = entryRoot || publicRoot;
|
|
745
796
|
entryRoot = ensureAbsolute(entryRoot, root);
|
|
746
|
-
const diagnostics =
|
|
797
|
+
const diagnostics = [
|
|
798
|
+
...program.getDeclarationDiagnostics(),
|
|
799
|
+
...program.getSemanticDiagnostics(),
|
|
800
|
+
...program.getSyntacticDiagnostics()
|
|
801
|
+
];
|
|
747
802
|
if (diagnostics?.length) {
|
|
748
803
|
logger.error(ts.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
749
804
|
}
|
|
750
805
|
if (typeof afterDiagnostic === "function") {
|
|
751
|
-
await
|
|
806
|
+
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
752
807
|
}
|
|
753
808
|
rootNames.forEach((file) => {
|
|
754
809
|
this.addWatchFile(file);
|
|
@@ -824,9 +879,10 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
824
879
|
const startTime = Date.now();
|
|
825
880
|
const outDir = outDirs[0];
|
|
826
881
|
const emittedFiles = /* @__PURE__ */ new Map();
|
|
882
|
+
const declareModules = [];
|
|
827
883
|
const writeOutput = async (path, content, outDir2, record = true) => {
|
|
828
884
|
if (typeof beforeWriteFile === "function") {
|
|
829
|
-
const result = await
|
|
885
|
+
const result = await unwrapPromise(beforeWriteFile(path, content));
|
|
830
886
|
if (result === false)
|
|
831
887
|
return;
|
|
832
888
|
if (result) {
|
|
@@ -870,17 +926,27 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
870
926
|
await runParallel(
|
|
871
927
|
cpus().length,
|
|
872
928
|
Array.from(outputFiles.entries()),
|
|
873
|
-
async ([
|
|
874
|
-
const isMapFile =
|
|
875
|
-
const baseDir = dirname(
|
|
929
|
+
async ([filePath, content]) => {
|
|
930
|
+
const isMapFile = filePath.endsWith(".map");
|
|
931
|
+
const baseDir = dirname(filePath);
|
|
876
932
|
if (!isMapFile && content) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
933
|
+
const result = transformCode({
|
|
934
|
+
filePath,
|
|
935
|
+
content,
|
|
936
|
+
aliases,
|
|
937
|
+
aliasesExclude,
|
|
938
|
+
staticImport,
|
|
939
|
+
clearPureImport
|
|
940
|
+
});
|
|
941
|
+
content = result.content;
|
|
942
|
+
declareModules.push(...result.declareModules);
|
|
880
943
|
}
|
|
881
|
-
|
|
944
|
+
filePath = resolve(
|
|
882
945
|
outDir,
|
|
883
|
-
relative(
|
|
946
|
+
relative(
|
|
947
|
+
entryRoot,
|
|
948
|
+
cleanVueFileName ? filePath.replace(".vue.d.ts", ".d.ts") : filePath
|
|
949
|
+
)
|
|
884
950
|
);
|
|
885
951
|
content = cleanVueFileName ? content.replace(vuePathRE, '"$1"') : content;
|
|
886
952
|
if (isMapFile) {
|
|
@@ -889,17 +955,17 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
889
955
|
sourceMap.sources = sourceMap.sources.map((source) => {
|
|
890
956
|
return normalizePath(
|
|
891
957
|
relative(
|
|
892
|
-
dirname(
|
|
958
|
+
dirname(filePath),
|
|
893
959
|
resolve(currentDir, relative(publicRoot, baseDir), source)
|
|
894
960
|
)
|
|
895
961
|
);
|
|
896
962
|
});
|
|
897
963
|
content = JSON.stringify(sourceMap);
|
|
898
964
|
} catch (e) {
|
|
899
|
-
logger.warn(`${logPrefix} ${yellow("Processing source map fail:")} ${
|
|
965
|
+
logger.warn(`${logPrefix} ${yellow("Processing source map fail:")} ${filePath}`);
|
|
900
966
|
}
|
|
901
967
|
}
|
|
902
|
-
await writeOutput(
|
|
968
|
+
await writeOutput(filePath, content, outDir);
|
|
903
969
|
}
|
|
904
970
|
);
|
|
905
971
|
bundleDebug("write output");
|
|
@@ -913,9 +979,6 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
913
979
|
const entryNames = Object.keys(entries);
|
|
914
980
|
const types = findTypesPath(pkg.publishConfig, pkg);
|
|
915
981
|
const multiple = entryNames.length > 1;
|
|
916
|
-
const cleanPath = (path) => {
|
|
917
|
-
return cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path;
|
|
918
|
-
};
|
|
919
982
|
let typesPath = cleanPath(types ? resolve(root, types) : resolve(outDir, indexName));
|
|
920
983
|
if (!multiple && !dtsRE.test(typesPath)) {
|
|
921
984
|
logger.warn(
|
|
@@ -928,23 +991,23 @@ ${logPrefix} ${yellow(
|
|
|
928
991
|
typesPath = `${typesPath.replace(tjsRE, "")}.d.${extPrefix(typesPath)}ts`;
|
|
929
992
|
}
|
|
930
993
|
for (const name of entryNames) {
|
|
931
|
-
const
|
|
932
|
-
if (existsSync(
|
|
994
|
+
const entryDtsPath = multiple ? cleanPath(resolve(outDir, tsToDts(name))) : typesPath;
|
|
995
|
+
if (existsSync(entryDtsPath))
|
|
933
996
|
continue;
|
|
934
|
-
const
|
|
935
|
-
resolve(outDir, relative(entryRoot,
|
|
997
|
+
const sourceEntry = normalizePath(
|
|
998
|
+
cleanPath(resolve(outDir, relative(entryRoot, tsToDts(entries[name]))))
|
|
936
999
|
);
|
|
937
|
-
let fromPath = normalizePath(relative(dirname(
|
|
1000
|
+
let fromPath = normalizePath(relative(dirname(entryDtsPath), sourceEntry));
|
|
938
1001
|
fromPath = fromPath.replace(dtsRE, "");
|
|
939
1002
|
fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
|
|
940
1003
|
let content = `export * from '${fromPath}'
|
|
941
1004
|
`;
|
|
942
|
-
if (
|
|
1005
|
+
if (emittedFiles.has(sourceEntry) && hasExportDefault(emittedFiles.get(sourceEntry))) {
|
|
943
1006
|
content += `import ${libName} from '${fromPath}'
|
|
944
1007
|
export default ${libName}
|
|
945
1008
|
`;
|
|
946
1009
|
}
|
|
947
|
-
await writeOutput(cleanPath(
|
|
1010
|
+
await writeOutput(cleanPath(entryDtsPath), content, outDir);
|
|
948
1011
|
}
|
|
949
1012
|
bundleDebug("insert index");
|
|
950
1013
|
if (rollupTypes) {
|
|
@@ -962,7 +1025,7 @@ export default ${libName}
|
|
|
962
1025
|
const compilerOptions2 = configPath ? getTsConfig(configPath, host.readFile).compilerOptions : rawCompilerOptions;
|
|
963
1026
|
if (multiple) {
|
|
964
1027
|
for (const name of entryNames) {
|
|
965
|
-
const path = cleanPath(resolve(outDir,
|
|
1028
|
+
const path = cleanPath(resolve(outDir, tsToDts(name)));
|
|
966
1029
|
rollupDeclarationFiles({
|
|
967
1030
|
root,
|
|
968
1031
|
configPath,
|
|
@@ -995,9 +1058,16 @@ export default ${libName}
|
|
|
995
1058
|
await runParallel(cpus().length, Array.from(emittedFiles.keys()), (f) => unlink(f));
|
|
996
1059
|
removeDirIfEmpty(outDir);
|
|
997
1060
|
emittedFiles.clear();
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1061
|
+
const declared = declareModules.join("\n");
|
|
1062
|
+
await runParallel(cpus().length, [...rollupFiles], async (filePath) => {
|
|
1063
|
+
await writeOutput(
|
|
1064
|
+
filePath,
|
|
1065
|
+
await readFile(filePath, "utf-8") + (declared ? `
|
|
1066
|
+
${declared}
|
|
1067
|
+
` : ""),
|
|
1068
|
+
dirname(filePath)
|
|
1069
|
+
);
|
|
1070
|
+
});
|
|
1001
1071
|
bundleDebug("rollup output");
|
|
1002
1072
|
}
|
|
1003
1073
|
}
|
|
@@ -1019,7 +1089,7 @@ export default ${libName}
|
|
|
1019
1089
|
});
|
|
1020
1090
|
}
|
|
1021
1091
|
if (typeof afterBuild === "function") {
|
|
1022
|
-
await
|
|
1092
|
+
await unwrapPromise(afterBuild(emittedFiles));
|
|
1023
1093
|
}
|
|
1024
1094
|
bundleDebug("finish");
|
|
1025
1095
|
logger.info(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "qmhc",
|
|
@@ -58,43 +58,44 @@
|
|
|
58
58
|
"volar"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@microsoft/api-extractor": "7.
|
|
61
|
+
"@microsoft/api-extractor": "7.43.0",
|
|
62
62
|
"@rollup/pluginutils": "^5.1.0",
|
|
63
|
-
"@vue/language-core": "^1.8.
|
|
63
|
+
"@vue/language-core": "^1.8.27",
|
|
64
64
|
"debug": "^4.3.4",
|
|
65
65
|
"kolorist": "^1.8.0",
|
|
66
|
-
"
|
|
66
|
+
"magic-string": "^0.30.8",
|
|
67
|
+
"vue-tsc": "^1.8.27"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@commitlint/cli": "^
|
|
70
|
+
"@commitlint/cli": "^19.2.1",
|
|
70
71
|
"@types/debug": "^4.1.12",
|
|
71
72
|
"@types/minimist": "^1.2.5",
|
|
72
|
-
"@types/node": "^20.
|
|
73
|
+
"@types/node": "^20.11.30",
|
|
73
74
|
"@types/prompts": "^2.4.9",
|
|
74
|
-
"@types/semver": "^7.5.
|
|
75
|
-
"@vexip-ui/commitlint-config": "^0.
|
|
76
|
-
"@vexip-ui/eslint-config": "^0.
|
|
75
|
+
"@types/semver": "^7.5.8",
|
|
76
|
+
"@vexip-ui/commitlint-config": "^0.4.0",
|
|
77
|
+
"@vexip-ui/eslint-config": "^0.12.0",
|
|
77
78
|
"@vexip-ui/prettier-config": "^0.2.0",
|
|
78
79
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
79
|
-
"@vue/eslint-config-typescript": "^
|
|
80
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
|
80
81
|
"conventional-changelog-cli": "^4.1.0",
|
|
81
|
-
"eslint": "^8.
|
|
82
|
+
"eslint": "^8.57.0",
|
|
82
83
|
"execa": "^8.0.1",
|
|
83
|
-
"husky": "^
|
|
84
|
+
"husky": "^9.0.11",
|
|
84
85
|
"is-ci": "^3.0.1",
|
|
85
|
-
"lint-staged": "^15.2.
|
|
86
|
+
"lint-staged": "^15.2.2",
|
|
86
87
|
"minimist": "^1.2.8",
|
|
87
88
|
"pinst": "^3.0.0",
|
|
88
|
-
"prettier": "^3.
|
|
89
|
-
"pretty-quick": "^
|
|
89
|
+
"prettier": "^3.2.5",
|
|
90
|
+
"pretty-quick": "^4.0.0",
|
|
90
91
|
"prompts": "^2.4.2",
|
|
91
92
|
"rimraf": "^5.0.5",
|
|
92
|
-
"semver": "^7.
|
|
93
|
-
"tsx": "^4.7.
|
|
94
|
-
"typescript": "5.
|
|
93
|
+
"semver": "^7.6.0",
|
|
94
|
+
"tsx": "^4.7.1",
|
|
95
|
+
"typescript": "5.4.3",
|
|
95
96
|
"unbuild": "^2.0.0",
|
|
96
|
-
"vite": "^5.
|
|
97
|
-
"vitest": "^1.
|
|
97
|
+
"vite": "^5.2.6",
|
|
98
|
+
"vitest": "^1.4.0"
|
|
98
99
|
},
|
|
99
100
|
"peerDependencies": {
|
|
100
101
|
"typescript": "*",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
},
|
|
108
109
|
"pnpm": {
|
|
109
110
|
"patchedDependencies": {
|
|
110
|
-
"@microsoft/api-extractor@7.
|
|
111
|
+
"@microsoft/api-extractor@7.43.0": "patches/@microsoft__api-extractor@7.43.0.patch"
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
}
|