vite-plugin-dts 3.0.0-beta.2 → 3.0.0-beta.3
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 +20 -12
- package/dist/index.mjs +20 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -128,7 +128,7 @@ function isRegExp(value) {
|
|
|
128
128
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
129
129
|
}
|
|
130
130
|
function isPromise(value) {
|
|
131
|
-
return !!value && typeof value
|
|
131
|
+
return !!value && (typeof value === "function" || typeof value === "object") && typeof value.then === "function";
|
|
132
132
|
}
|
|
133
133
|
function ensureAbsolute(path, root) {
|
|
134
134
|
return path ? node_path.isAbsolute(path) ? path : node_path.resolve(root, path) : root;
|
|
@@ -467,6 +467,8 @@ ${kolorist.cyan(
|
|
|
467
467
|
program = vueTsc.createProgram({ host, rootNames, options: compilerOptions });
|
|
468
468
|
libName = libName || "_default";
|
|
469
469
|
indexName = indexName || defaultIndex;
|
|
470
|
+
entryRoot = entryRoot || queryPublicPath(rootNames);
|
|
471
|
+
entryRoot = ensureAbsolute(entryRoot, root);
|
|
470
472
|
const diagnostics = program.getDeclarationDiagnostics();
|
|
471
473
|
if (diagnostics?.length) {
|
|
472
474
|
logger.error(ts__default.formatDiagnostics(diagnostics, host));
|
|
@@ -496,11 +498,14 @@ ${kolorist.cyan(
|
|
|
496
498
|
const outDir = outDirs[0];
|
|
497
499
|
const service = program.__vue.languageService;
|
|
498
500
|
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
499
|
-
outputFiles.set(
|
|
501
|
+
outputFiles.set(normalizePath(outputFile.name), outputFile.text);
|
|
500
502
|
}
|
|
501
503
|
const dtsId = id.replace(tjsRE, ".d.ts");
|
|
502
504
|
const dtsSourceFile = program.getSourceFile(dtsId);
|
|
503
|
-
dtsSourceFile && filter(dtsSourceFile.fileName) && outputFiles.set(
|
|
505
|
+
dtsSourceFile && filter(dtsSourceFile.fileName) && outputFiles.set(
|
|
506
|
+
resolve(outDir, node_path.relative(entryRoot, dtsSourceFile.fileName)),
|
|
507
|
+
dtsSourceFile.getFullText()
|
|
508
|
+
);
|
|
504
509
|
},
|
|
505
510
|
watchChange(id) {
|
|
506
511
|
if (host && program && watchExtensionRE.test(id)) {
|
|
@@ -528,18 +533,19 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
528
533
|
if (!filter(sourceFile.fileName))
|
|
529
534
|
continue;
|
|
530
535
|
if (copyDtsFiles && dtsRE.test(sourceFile.fileName)) {
|
|
531
|
-
outputFiles.set(
|
|
536
|
+
outputFiles.set(
|
|
537
|
+
resolve(outDir, node_path.relative(entryRoot, sourceFile.fileName)),
|
|
538
|
+
sourceFile.getFullText()
|
|
539
|
+
);
|
|
532
540
|
}
|
|
533
541
|
if (rootFiles.has(sourceFile.fileName)) {
|
|
534
542
|
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
535
|
-
outputFiles.set(
|
|
543
|
+
outputFiles.set(normalizePath(outputFile.name), outputFile.text);
|
|
536
544
|
}
|
|
537
545
|
rootFiles.delete(sourceFile.fileName);
|
|
538
546
|
}
|
|
539
547
|
}
|
|
540
548
|
bundleDebug("emit output patch");
|
|
541
|
-
entryRoot = entryRoot || queryPublicPath(Array.from(outputFiles.keys()));
|
|
542
|
-
entryRoot = ensureAbsolute(entryRoot, root);
|
|
543
549
|
await runParallel(
|
|
544
550
|
node_os.cpus().length,
|
|
545
551
|
Array.from(outputFiles.entries()),
|
|
@@ -547,13 +553,15 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
547
553
|
const isMapFile = path.endsWith(".map");
|
|
548
554
|
if (!isMapFile && content) {
|
|
549
555
|
content = clearPureImport ? removePureImport(content) : content;
|
|
550
|
-
content = transformAliasImport(
|
|
556
|
+
content = transformAliasImport(
|
|
557
|
+
resolve(entryRoot, node_path.relative(outDir, path)),
|
|
558
|
+
content,
|
|
559
|
+
aliases,
|
|
560
|
+
aliasesExclude
|
|
561
|
+
);
|
|
551
562
|
content = staticImport || rollupTypes ? transformDynamicImport(content) : content;
|
|
552
563
|
}
|
|
553
|
-
path =
|
|
554
|
-
outDir,
|
|
555
|
-
node_path.relative(entryRoot, cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path)
|
|
556
|
-
);
|
|
564
|
+
path = cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path;
|
|
557
565
|
content = cleanVueFileName ? content.replace(/['"](.+)\.vue['"]/g, '"$1"') : content;
|
|
558
566
|
if (typeof beforeWriteFile === "function") {
|
|
559
567
|
const result = beforeWriteFile(path, content);
|
package/dist/index.mjs
CHANGED
|
@@ -128,7 +128,7 @@ function isRegExp(value) {
|
|
|
128
128
|
return Object.prototype.toString.call(value) === "[object RegExp]";
|
|
129
129
|
}
|
|
130
130
|
function isPromise(value) {
|
|
131
|
-
return !!value && typeof value
|
|
131
|
+
return !!value && (typeof value === "function" || typeof value === "object") && typeof value.then === "function";
|
|
132
132
|
}
|
|
133
133
|
function ensureAbsolute(path, root) {
|
|
134
134
|
return path ? isAbsolute(path) ? path : resolve$1(root, path) : root;
|
|
@@ -467,6 +467,8 @@ ${cyan(
|
|
|
467
467
|
program = createProgram({ host, rootNames, options: compilerOptions });
|
|
468
468
|
libName = libName || "_default";
|
|
469
469
|
indexName = indexName || defaultIndex;
|
|
470
|
+
entryRoot = entryRoot || queryPublicPath(rootNames);
|
|
471
|
+
entryRoot = ensureAbsolute(entryRoot, root);
|
|
470
472
|
const diagnostics = program.getDeclarationDiagnostics();
|
|
471
473
|
if (diagnostics?.length) {
|
|
472
474
|
logger.error(ts.formatDiagnostics(diagnostics, host));
|
|
@@ -496,11 +498,14 @@ ${cyan(
|
|
|
496
498
|
const outDir = outDirs[0];
|
|
497
499
|
const service = program.__vue.languageService;
|
|
498
500
|
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
499
|
-
outputFiles.set(
|
|
501
|
+
outputFiles.set(normalizePath(outputFile.name), outputFile.text);
|
|
500
502
|
}
|
|
501
503
|
const dtsId = id.replace(tjsRE, ".d.ts");
|
|
502
504
|
const dtsSourceFile = program.getSourceFile(dtsId);
|
|
503
|
-
dtsSourceFile && filter(dtsSourceFile.fileName) && outputFiles.set(
|
|
505
|
+
dtsSourceFile && filter(dtsSourceFile.fileName) && outputFiles.set(
|
|
506
|
+
resolve(outDir, relative(entryRoot, dtsSourceFile.fileName)),
|
|
507
|
+
dtsSourceFile.getFullText()
|
|
508
|
+
);
|
|
504
509
|
},
|
|
505
510
|
watchChange(id) {
|
|
506
511
|
if (host && program && watchExtensionRE.test(id)) {
|
|
@@ -528,18 +533,19 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
528
533
|
if (!filter(sourceFile.fileName))
|
|
529
534
|
continue;
|
|
530
535
|
if (copyDtsFiles && dtsRE.test(sourceFile.fileName)) {
|
|
531
|
-
outputFiles.set(
|
|
536
|
+
outputFiles.set(
|
|
537
|
+
resolve(outDir, relative(entryRoot, sourceFile.fileName)),
|
|
538
|
+
sourceFile.getFullText()
|
|
539
|
+
);
|
|
532
540
|
}
|
|
533
541
|
if (rootFiles.has(sourceFile.fileName)) {
|
|
534
542
|
for (const outputFile of service.getEmitOutput(sourceFile.fileName, true).outputFiles) {
|
|
535
|
-
outputFiles.set(
|
|
543
|
+
outputFiles.set(normalizePath(outputFile.name), outputFile.text);
|
|
536
544
|
}
|
|
537
545
|
rootFiles.delete(sourceFile.fileName);
|
|
538
546
|
}
|
|
539
547
|
}
|
|
540
548
|
bundleDebug("emit output patch");
|
|
541
|
-
entryRoot = entryRoot || queryPublicPath(Array.from(outputFiles.keys()));
|
|
542
|
-
entryRoot = ensureAbsolute(entryRoot, root);
|
|
543
549
|
await runParallel(
|
|
544
550
|
cpus().length,
|
|
545
551
|
Array.from(outputFiles.entries()),
|
|
@@ -547,13 +553,15 @@ ${logPrefix} Start generate declaration files...`));
|
|
|
547
553
|
const isMapFile = path.endsWith(".map");
|
|
548
554
|
if (!isMapFile && content) {
|
|
549
555
|
content = clearPureImport ? removePureImport(content) : content;
|
|
550
|
-
content = transformAliasImport(
|
|
556
|
+
content = transformAliasImport(
|
|
557
|
+
resolve(entryRoot, relative(outDir, path)),
|
|
558
|
+
content,
|
|
559
|
+
aliases,
|
|
560
|
+
aliasesExclude
|
|
561
|
+
);
|
|
551
562
|
content = staticImport || rollupTypes ? transformDynamicImport(content) : content;
|
|
552
563
|
}
|
|
553
|
-
path =
|
|
554
|
-
outDir,
|
|
555
|
-
relative(entryRoot, cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path)
|
|
556
|
-
);
|
|
564
|
+
path = cleanVueFileName ? path.replace(".vue.d.ts", ".d.ts") : path;
|
|
557
565
|
content = cleanVueFileName ? content.replace(/['"](.+)\.vue['"]/g, '"$1"') : content;
|
|
558
566
|
if (typeof beforeWriteFile === "function") {
|
|
559
567
|
const result = beforeWriteFile(path, content);
|