vite-plugin-dts 4.5.1 → 4.5.4
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/dist/index.cjs +39 -15
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +39 -15
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -472,7 +472,7 @@ function VueResolver() {
|
|
|
472
472
|
const sourceFile = program.getSourceFile(id) || program.getSourceFile(id + ".ts") || program.getSourceFile(id + ".js") || program.getSourceFile(id + ".tsx") || program.getSourceFile(id + ".jsx");
|
|
473
473
|
if (!sourceFile) return [];
|
|
474
474
|
const outputs = [];
|
|
475
|
-
program.emit(
|
|
475
|
+
const { emitSkipped, diagnostics } = program.emit(
|
|
476
476
|
sourceFile,
|
|
477
477
|
(path, content) => {
|
|
478
478
|
outputs.push({ path, content });
|
|
@@ -480,7 +480,13 @@ function VueResolver() {
|
|
|
480
480
|
undefined,
|
|
481
481
|
true
|
|
482
482
|
);
|
|
483
|
-
if (!program.getCompilerOptions().declarationMap)
|
|
483
|
+
if (!program.getCompilerOptions().declarationMap) {
|
|
484
|
+
return {
|
|
485
|
+
outputs,
|
|
486
|
+
emitSkipped,
|
|
487
|
+
diagnostics
|
|
488
|
+
};
|
|
489
|
+
}
|
|
484
490
|
const [beforeScript] = code.split(/\s*<script.*>/);
|
|
485
491
|
const beforeLines = beforeScript.split("\n").length;
|
|
486
492
|
for (const output of outputs) {
|
|
@@ -498,7 +504,11 @@ function VueResolver() {
|
|
|
498
504
|
}
|
|
499
505
|
}
|
|
500
506
|
}
|
|
501
|
-
return
|
|
507
|
+
return {
|
|
508
|
+
outputs,
|
|
509
|
+
emitSkipped,
|
|
510
|
+
diagnostics
|
|
511
|
+
};
|
|
502
512
|
}
|
|
503
513
|
};
|
|
504
514
|
}
|
|
@@ -803,6 +813,7 @@ function dtsPlugin(options = {}) {
|
|
|
803
813
|
const rootFiles = /* @__PURE__ */ new Set();
|
|
804
814
|
const outputFiles = /* @__PURE__ */ new Map();
|
|
805
815
|
const transformedFiles = /* @__PURE__ */ new Set();
|
|
816
|
+
const diagnostics = [];
|
|
806
817
|
const setOutputFile = (path, content) => {
|
|
807
818
|
outputFiles.set(path, content);
|
|
808
819
|
};
|
|
@@ -853,7 +864,7 @@ function dtsPlugin(options = {}) {
|
|
|
853
864
|
entries = { ...input };
|
|
854
865
|
}
|
|
855
866
|
const filename = config.build.lib.fileName ?? defaultIndex;
|
|
856
|
-
const entry = typeof config.build.lib.entry === "string" ? config.build.lib.entry : Object.
|
|
867
|
+
const entry = typeof config.build.lib.entry === "string" ? config.build.lib.entry : Object.keys(config.build.lib.entry)[0];
|
|
857
868
|
libName = config.build.lib.name || "_default";
|
|
858
869
|
indexName = typeof filename === "string" ? filename : filename("es", entry);
|
|
859
870
|
if (!dtsRE.test(indexName)) {
|
|
@@ -981,17 +992,11 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
981
992
|
publicRoot = normalizePath(publicRoot);
|
|
982
993
|
entryRoot = entryRoot || publicRoot;
|
|
983
994
|
entryRoot = ensureAbsolute(entryRoot, root);
|
|
984
|
-
|
|
995
|
+
diagnostics.push(
|
|
985
996
|
...program.getDeclarationDiagnostics(),
|
|
986
997
|
...program.getSemanticDiagnostics(),
|
|
987
998
|
...program.getSyntacticDiagnostics()
|
|
988
|
-
|
|
989
|
-
if (diagnostics?.length) {
|
|
990
|
-
logger.error(ts__default.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
991
|
-
}
|
|
992
|
-
if (typeof afterDiagnostic === "function") {
|
|
993
|
-
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
994
|
-
}
|
|
999
|
+
);
|
|
995
1000
|
for (const file of rootNames) {
|
|
996
1001
|
this.addWatchFile(file);
|
|
997
1002
|
rootFiles.add(file);
|
|
@@ -1018,7 +1023,16 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
1018
1023
|
host,
|
|
1019
1024
|
program
|
|
1020
1025
|
});
|
|
1021
|
-
|
|
1026
|
+
let output;
|
|
1027
|
+
if (Array.isArray(result)) {
|
|
1028
|
+
output = result;
|
|
1029
|
+
} else {
|
|
1030
|
+
output = result.outputs;
|
|
1031
|
+
if (result.emitSkipped && result.diagnostics?.length) {
|
|
1032
|
+
diagnostics.push(...result.diagnostics);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
for (const { path, content } of output) {
|
|
1022
1036
|
setOutputFile(
|
|
1023
1037
|
resolve(publicRoot, node_path.relative(outDir, ensureAbsolute(path, outDir))),
|
|
1024
1038
|
content
|
|
@@ -1027,7 +1041,7 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
1027
1041
|
} else {
|
|
1028
1042
|
const sourceFile = program.getSourceFile(id);
|
|
1029
1043
|
if (sourceFile) {
|
|
1030
|
-
program.emit(
|
|
1044
|
+
const result = program.emit(
|
|
1031
1045
|
sourceFile,
|
|
1032
1046
|
(name, text) => {
|
|
1033
1047
|
setOutputFile(
|
|
@@ -1038,6 +1052,9 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
1038
1052
|
undefined,
|
|
1039
1053
|
true
|
|
1040
1054
|
);
|
|
1055
|
+
if (result.emitSkipped && result.diagnostics.length) {
|
|
1056
|
+
diagnostics.push(...result.diagnostics);
|
|
1057
|
+
}
|
|
1041
1058
|
}
|
|
1042
1059
|
}
|
|
1043
1060
|
const dtsId = id.replace(tjsRE, "") + ".d.ts";
|
|
@@ -1070,6 +1087,12 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
1070
1087
|
logger.info(kolorist.green(`
|
|
1071
1088
|
${logPrefix} Start generate declaration files...`));
|
|
1072
1089
|
const startTime = Date.now();
|
|
1090
|
+
if (diagnostics?.length) {
|
|
1091
|
+
logger.error(ts__default.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
1092
|
+
}
|
|
1093
|
+
if (typeof afterDiagnostic === "function") {
|
|
1094
|
+
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
1095
|
+
}
|
|
1073
1096
|
const outDir = outDirs[0];
|
|
1074
1097
|
const emittedFiles = /* @__PURE__ */ new Map();
|
|
1075
1098
|
const declareModules = [];
|
|
@@ -1244,7 +1267,7 @@ ${content}`;
|
|
|
1244
1267
|
const compilerOptions2 = configPath ? getTsConfig(configPath, host.readFile).compilerOptions : rawCompilerOptions;
|
|
1245
1268
|
const rollup = async (path) => {
|
|
1246
1269
|
const result = rollupDeclarationFiles({
|
|
1247
|
-
root,
|
|
1270
|
+
root: publicRoot,
|
|
1248
1271
|
configPath,
|
|
1249
1272
|
compilerOptions: compilerOptions2,
|
|
1250
1273
|
outDir,
|
|
@@ -1299,6 +1322,7 @@ ${declared}` : ""),
|
|
|
1299
1322
|
);
|
|
1300
1323
|
});
|
|
1301
1324
|
}
|
|
1325
|
+
diagnostics.length = 0;
|
|
1302
1326
|
if (typeof afterBuild === "function") {
|
|
1303
1327
|
await unwrapPromise(afterBuild(emittedFiles));
|
|
1304
1328
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,13 @@ interface Resolver {
|
|
|
29
29
|
host: ts.CompilerHost;
|
|
30
30
|
program: ts.Program;
|
|
31
31
|
}) => MaybePromise<{
|
|
32
|
+
outputs: {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}[];
|
|
36
|
+
emitSkipped?: boolean;
|
|
37
|
+
diagnostics?: readonly ts.Diagnostic[];
|
|
38
|
+
} | {
|
|
32
39
|
path: string;
|
|
33
40
|
content: string;
|
|
34
41
|
}[]>;
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,13 @@ interface Resolver {
|
|
|
29
29
|
host: ts.CompilerHost;
|
|
30
30
|
program: ts.Program;
|
|
31
31
|
}) => MaybePromise<{
|
|
32
|
+
outputs: {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}[];
|
|
36
|
+
emitSkipped?: boolean;
|
|
37
|
+
diagnostics?: readonly ts.Diagnostic[];
|
|
38
|
+
} | {
|
|
32
39
|
path: string;
|
|
33
40
|
content: string;
|
|
34
41
|
}[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ interface Resolver {
|
|
|
29
29
|
host: ts.CompilerHost;
|
|
30
30
|
program: ts.Program;
|
|
31
31
|
}) => MaybePromise<{
|
|
32
|
+
outputs: {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}[];
|
|
36
|
+
emitSkipped?: boolean;
|
|
37
|
+
diagnostics?: readonly ts.Diagnostic[];
|
|
38
|
+
} | {
|
|
32
39
|
path: string;
|
|
33
40
|
content: string;
|
|
34
41
|
}[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -468,7 +468,7 @@ function VueResolver() {
|
|
|
468
468
|
const sourceFile = program.getSourceFile(id) || program.getSourceFile(id + ".ts") || program.getSourceFile(id + ".js") || program.getSourceFile(id + ".tsx") || program.getSourceFile(id + ".jsx");
|
|
469
469
|
if (!sourceFile) return [];
|
|
470
470
|
const outputs = [];
|
|
471
|
-
program.emit(
|
|
471
|
+
const { emitSkipped, diagnostics } = program.emit(
|
|
472
472
|
sourceFile,
|
|
473
473
|
(path, content) => {
|
|
474
474
|
outputs.push({ path, content });
|
|
@@ -476,7 +476,13 @@ function VueResolver() {
|
|
|
476
476
|
undefined,
|
|
477
477
|
true
|
|
478
478
|
);
|
|
479
|
-
if (!program.getCompilerOptions().declarationMap)
|
|
479
|
+
if (!program.getCompilerOptions().declarationMap) {
|
|
480
|
+
return {
|
|
481
|
+
outputs,
|
|
482
|
+
emitSkipped,
|
|
483
|
+
diagnostics
|
|
484
|
+
};
|
|
485
|
+
}
|
|
480
486
|
const [beforeScript] = code.split(/\s*<script.*>/);
|
|
481
487
|
const beforeLines = beforeScript.split("\n").length;
|
|
482
488
|
for (const output of outputs) {
|
|
@@ -494,7 +500,11 @@ function VueResolver() {
|
|
|
494
500
|
}
|
|
495
501
|
}
|
|
496
502
|
}
|
|
497
|
-
return
|
|
503
|
+
return {
|
|
504
|
+
outputs,
|
|
505
|
+
emitSkipped,
|
|
506
|
+
diagnostics
|
|
507
|
+
};
|
|
498
508
|
}
|
|
499
509
|
};
|
|
500
510
|
}
|
|
@@ -799,6 +809,7 @@ function dtsPlugin(options = {}) {
|
|
|
799
809
|
const rootFiles = /* @__PURE__ */ new Set();
|
|
800
810
|
const outputFiles = /* @__PURE__ */ new Map();
|
|
801
811
|
const transformedFiles = /* @__PURE__ */ new Set();
|
|
812
|
+
const diagnostics = [];
|
|
802
813
|
const setOutputFile = (path, content) => {
|
|
803
814
|
outputFiles.set(path, content);
|
|
804
815
|
};
|
|
@@ -849,7 +860,7 @@ function dtsPlugin(options = {}) {
|
|
|
849
860
|
entries = { ...input };
|
|
850
861
|
}
|
|
851
862
|
const filename = config.build.lib.fileName ?? defaultIndex;
|
|
852
|
-
const entry = typeof config.build.lib.entry === "string" ? config.build.lib.entry : Object.
|
|
863
|
+
const entry = typeof config.build.lib.entry === "string" ? config.build.lib.entry : Object.keys(config.build.lib.entry)[0];
|
|
853
864
|
libName = config.build.lib.name || "_default";
|
|
854
865
|
indexName = typeof filename === "string" ? filename : filename("es", entry);
|
|
855
866
|
if (!dtsRE.test(indexName)) {
|
|
@@ -977,17 +988,11 @@ ${logPrefix} ${yellow(
|
|
|
977
988
|
publicRoot = normalizePath(publicRoot);
|
|
978
989
|
entryRoot = entryRoot || publicRoot;
|
|
979
990
|
entryRoot = ensureAbsolute(entryRoot, root);
|
|
980
|
-
|
|
991
|
+
diagnostics.push(
|
|
981
992
|
...program.getDeclarationDiagnostics(),
|
|
982
993
|
...program.getSemanticDiagnostics(),
|
|
983
994
|
...program.getSyntacticDiagnostics()
|
|
984
|
-
|
|
985
|
-
if (diagnostics?.length) {
|
|
986
|
-
logger.error(ts.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
987
|
-
}
|
|
988
|
-
if (typeof afterDiagnostic === "function") {
|
|
989
|
-
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
990
|
-
}
|
|
995
|
+
);
|
|
991
996
|
for (const file of rootNames) {
|
|
992
997
|
this.addWatchFile(file);
|
|
993
998
|
rootFiles.add(file);
|
|
@@ -1014,7 +1019,16 @@ ${logPrefix} ${yellow(
|
|
|
1014
1019
|
host,
|
|
1015
1020
|
program
|
|
1016
1021
|
});
|
|
1017
|
-
|
|
1022
|
+
let output;
|
|
1023
|
+
if (Array.isArray(result)) {
|
|
1024
|
+
output = result;
|
|
1025
|
+
} else {
|
|
1026
|
+
output = result.outputs;
|
|
1027
|
+
if (result.emitSkipped && result.diagnostics?.length) {
|
|
1028
|
+
diagnostics.push(...result.diagnostics);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
for (const { path, content } of output) {
|
|
1018
1032
|
setOutputFile(
|
|
1019
1033
|
resolve(publicRoot, relative(outDir, ensureAbsolute(path, outDir))),
|
|
1020
1034
|
content
|
|
@@ -1023,7 +1037,7 @@ ${logPrefix} ${yellow(
|
|
|
1023
1037
|
} else {
|
|
1024
1038
|
const sourceFile = program.getSourceFile(id);
|
|
1025
1039
|
if (sourceFile) {
|
|
1026
|
-
program.emit(
|
|
1040
|
+
const result = program.emit(
|
|
1027
1041
|
sourceFile,
|
|
1028
1042
|
(name, text) => {
|
|
1029
1043
|
setOutputFile(
|
|
@@ -1034,6 +1048,9 @@ ${logPrefix} ${yellow(
|
|
|
1034
1048
|
undefined,
|
|
1035
1049
|
true
|
|
1036
1050
|
);
|
|
1051
|
+
if (result.emitSkipped && result.diagnostics.length) {
|
|
1052
|
+
diagnostics.push(...result.diagnostics);
|
|
1053
|
+
}
|
|
1037
1054
|
}
|
|
1038
1055
|
}
|
|
1039
1056
|
const dtsId = id.replace(tjsRE, "") + ".d.ts";
|
|
@@ -1066,6 +1083,12 @@ ${logPrefix} ${yellow(
|
|
|
1066
1083
|
logger.info(green(`
|
|
1067
1084
|
${logPrefix} Start generate declaration files...`));
|
|
1068
1085
|
const startTime = Date.now();
|
|
1086
|
+
if (diagnostics?.length) {
|
|
1087
|
+
logger.error(ts.formatDiagnosticsWithColorAndContext(diagnostics, host));
|
|
1088
|
+
}
|
|
1089
|
+
if (typeof afterDiagnostic === "function") {
|
|
1090
|
+
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
1091
|
+
}
|
|
1069
1092
|
const outDir = outDirs[0];
|
|
1070
1093
|
const emittedFiles = /* @__PURE__ */ new Map();
|
|
1071
1094
|
const declareModules = [];
|
|
@@ -1240,7 +1263,7 @@ ${content}`;
|
|
|
1240
1263
|
const compilerOptions2 = configPath ? getTsConfig(configPath, host.readFile).compilerOptions : rawCompilerOptions;
|
|
1241
1264
|
const rollup = async (path) => {
|
|
1242
1265
|
const result = rollupDeclarationFiles({
|
|
1243
|
-
root,
|
|
1266
|
+
root: publicRoot,
|
|
1244
1267
|
configPath,
|
|
1245
1268
|
compilerOptions: compilerOptions2,
|
|
1246
1269
|
outDir,
|
|
@@ -1295,6 +1318,7 @@ ${declared}` : ""),
|
|
|
1295
1318
|
);
|
|
1296
1319
|
});
|
|
1297
1320
|
}
|
|
1321
|
+
diagnostics.length = 0;
|
|
1298
1322
|
if (typeof afterBuild === "function") {
|
|
1299
1323
|
await unwrapPromise(afterBuild(emittedFiles));
|
|
1300
1324
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "qmhc",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@microsoft/api-extractor": "^7.50.1",
|
|
40
40
|
"@rollup/pluginutils": "^5.1.4",
|
|
41
41
|
"@volar/typescript": "^2.4.11",
|
|
42
|
-
"@vue/language-core": "2.2.
|
|
42
|
+
"@vue/language-core": "2.2.0",
|
|
43
43
|
"compare-versions": "^6.1.1",
|
|
44
44
|
"debug": "^4.4.0",
|
|
45
45
|
"kolorist": "^1.8.0",
|