vite-plugin-dts 4.2.3-dev.2 → 4.2.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/LICENSE +21 -21
- package/README.md +417 -417
- package/README.zh-CN.md +417 -417
- package/dist/index.cjs +17 -7
- package/dist/index.mjs +17 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -260,7 +260,7 @@ function parseTsAliases(basePath, paths) {
|
|
|
260
260
|
const result = [];
|
|
261
261
|
for (const [pathWithAsterisk, replacements] of Object.entries(paths)) {
|
|
262
262
|
const find = new RegExp(
|
|
263
|
-
`^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "(
|
|
263
|
+
`^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "(?!\\.{1,2}\\/)([^*]+)")}$`
|
|
264
264
|
);
|
|
265
265
|
let index = 1;
|
|
266
266
|
result.push({
|
|
@@ -620,7 +620,7 @@ function transformCode(options) {
|
|
|
620
620
|
}
|
|
621
621
|
if (ts__default.isModuleDeclaration(node) && node.body && ts__default.isModuleBlock(node.body)) {
|
|
622
622
|
if (ts__default.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
|
|
623
|
-
s.remove(node.pos, node.end
|
|
623
|
+
s.remove(node.pos, node.end);
|
|
624
624
|
} else if (node.modifiers?.[0] && node.modifiers[0].kind === ts__default.SyntaxKind.DeclareKeyword && !node.body.statements.some(
|
|
625
625
|
(s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
|
|
626
626
|
)) {
|
|
@@ -757,6 +757,7 @@ function dtsPlugin(options = {}) {
|
|
|
757
757
|
let host;
|
|
758
758
|
let program;
|
|
759
759
|
let filter;
|
|
760
|
+
let rootNames = [];
|
|
760
761
|
let rebuildProgram;
|
|
761
762
|
let bundled = false;
|
|
762
763
|
let timeRecord = 0;
|
|
@@ -883,7 +884,13 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
883
884
|
if (!outDirs) {
|
|
884
885
|
outDirs = options.outDir ? ensureArray(options.outDir).map((d) => ensureAbsolute(d, root)) : [ensureAbsolute(content?.raw.compilerOptions?.outDir || "dist", root)];
|
|
885
886
|
}
|
|
886
|
-
const {
|
|
887
|
+
const {
|
|
888
|
+
// Here we are using the default value to set the `baseUrl` to the current directory if no value exists. This is
|
|
889
|
+
// the same behavior as the TS Compiler. See TS source:
|
|
890
|
+
// https://github.com/microsoft/TypeScript/blob/3386e943215613c40f68ba0b108cda1ddb7faee1/src/compiler/utilities.ts#L6493-L6501
|
|
891
|
+
baseUrl = compilerOptions.paths ? process.cwd() : void 0,
|
|
892
|
+
paths
|
|
893
|
+
} = compilerOptions;
|
|
887
894
|
if (pathsToAliases && baseUrl && paths) {
|
|
888
895
|
aliases.push(
|
|
889
896
|
...parseTsAliases(ensureAbsolute(baseUrl, configPath ? node_path.dirname(configPath) : root), paths)
|
|
@@ -904,7 +911,7 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
904
911
|
);
|
|
905
912
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
906
913
|
filter = pluginutils.createFilter(include, exclude);
|
|
907
|
-
|
|
914
|
+
rootNames = [
|
|
908
915
|
...new Set(
|
|
909
916
|
Object.values(entries).map((entry) => ensureAbsolute(entry, root)).concat(content?.fileNames.filter(filter) || []).map(normalizePath)
|
|
910
917
|
)
|
|
@@ -938,10 +945,10 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
938
945
|
if (typeof afterDiagnostic === "function") {
|
|
939
946
|
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
940
947
|
}
|
|
941
|
-
|
|
948
|
+
for (const file of rootNames) {
|
|
942
949
|
this.addWatchFile(file);
|
|
943
950
|
rootFiles.add(file);
|
|
944
|
-
}
|
|
951
|
+
}
|
|
945
952
|
bundleDebug("create ts program");
|
|
946
953
|
timeRecord += Date.now() - startTime;
|
|
947
954
|
},
|
|
@@ -999,7 +1006,10 @@ ${logPrefix} ${kolorist.yellow(
|
|
|
999
1006
|
id = id.split("?")[0];
|
|
1000
1007
|
const sourceFile = host.getSourceFile(id, ts__default.ScriptTarget.ESNext);
|
|
1001
1008
|
if (sourceFile) {
|
|
1002
|
-
|
|
1009
|
+
for (const file of rootNames) {
|
|
1010
|
+
rootFiles.add(file);
|
|
1011
|
+
}
|
|
1012
|
+
rootFiles.add(normalizePath(sourceFile.fileName));
|
|
1003
1013
|
bundled = false;
|
|
1004
1014
|
timeRecord = 0;
|
|
1005
1015
|
program = rebuildProgram();
|
package/dist/index.mjs
CHANGED
|
@@ -256,7 +256,7 @@ function parseTsAliases(basePath, paths) {
|
|
|
256
256
|
const result = [];
|
|
257
257
|
for (const [pathWithAsterisk, replacements] of Object.entries(paths)) {
|
|
258
258
|
const find = new RegExp(
|
|
259
|
-
`^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "(
|
|
259
|
+
`^${pathWithAsterisk.replace(regexpSymbolRE, "\\$1").replace(asteriskRE, "(?!\\.{1,2}\\/)([^*]+)")}$`
|
|
260
260
|
);
|
|
261
261
|
let index = 1;
|
|
262
262
|
result.push({
|
|
@@ -616,7 +616,7 @@ function transformCode(options) {
|
|
|
616
616
|
}
|
|
617
617
|
if (ts.isModuleDeclaration(node) && node.body && ts.isModuleBlock(node.body)) {
|
|
618
618
|
if (ts.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
|
|
619
|
-
s.remove(node.pos, node.end
|
|
619
|
+
s.remove(node.pos, node.end);
|
|
620
620
|
} else if (node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && !node.body.statements.some(
|
|
621
621
|
(s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
|
|
622
622
|
)) {
|
|
@@ -753,6 +753,7 @@ function dtsPlugin(options = {}) {
|
|
|
753
753
|
let host;
|
|
754
754
|
let program;
|
|
755
755
|
let filter;
|
|
756
|
+
let rootNames = [];
|
|
756
757
|
let rebuildProgram;
|
|
757
758
|
let bundled = false;
|
|
758
759
|
let timeRecord = 0;
|
|
@@ -879,7 +880,13 @@ ${logPrefix} ${yellow(
|
|
|
879
880
|
if (!outDirs) {
|
|
880
881
|
outDirs = options.outDir ? ensureArray(options.outDir).map((d) => ensureAbsolute(d, root)) : [ensureAbsolute(content?.raw.compilerOptions?.outDir || "dist", root)];
|
|
881
882
|
}
|
|
882
|
-
const {
|
|
883
|
+
const {
|
|
884
|
+
// Here we are using the default value to set the `baseUrl` to the current directory if no value exists. This is
|
|
885
|
+
// the same behavior as the TS Compiler. See TS source:
|
|
886
|
+
// https://github.com/microsoft/TypeScript/blob/3386e943215613c40f68ba0b108cda1ddb7faee1/src/compiler/utilities.ts#L6493-L6501
|
|
887
|
+
baseUrl = compilerOptions.paths ? process.cwd() : void 0,
|
|
888
|
+
paths
|
|
889
|
+
} = compilerOptions;
|
|
883
890
|
if (pathsToAliases && baseUrl && paths) {
|
|
884
891
|
aliases.push(
|
|
885
892
|
...parseTsAliases(ensureAbsolute(baseUrl, configPath ? dirname(configPath) : root), paths)
|
|
@@ -900,7 +907,7 @@ ${logPrefix} ${yellow(
|
|
|
900
907
|
);
|
|
901
908
|
exclude = computeGlobs(options.exclude, content?.raw.exclude, "node_modules/**");
|
|
902
909
|
filter = createFilter(include, exclude);
|
|
903
|
-
|
|
910
|
+
rootNames = [
|
|
904
911
|
...new Set(
|
|
905
912
|
Object.values(entries).map((entry) => ensureAbsolute(entry, root)).concat(content?.fileNames.filter(filter) || []).map(normalizePath)
|
|
906
913
|
)
|
|
@@ -934,10 +941,10 @@ ${logPrefix} ${yellow(
|
|
|
934
941
|
if (typeof afterDiagnostic === "function") {
|
|
935
942
|
await unwrapPromise(afterDiagnostic(diagnostics));
|
|
936
943
|
}
|
|
937
|
-
|
|
944
|
+
for (const file of rootNames) {
|
|
938
945
|
this.addWatchFile(file);
|
|
939
946
|
rootFiles.add(file);
|
|
940
|
-
}
|
|
947
|
+
}
|
|
941
948
|
bundleDebug("create ts program");
|
|
942
949
|
timeRecord += Date.now() - startTime;
|
|
943
950
|
},
|
|
@@ -995,7 +1002,10 @@ ${logPrefix} ${yellow(
|
|
|
995
1002
|
id = id.split("?")[0];
|
|
996
1003
|
const sourceFile = host.getSourceFile(id, ts.ScriptTarget.ESNext);
|
|
997
1004
|
if (sourceFile) {
|
|
998
|
-
|
|
1005
|
+
for (const file of rootNames) {
|
|
1006
|
+
rootFiles.add(file);
|
|
1007
|
+
}
|
|
1008
|
+
rootFiles.add(normalizePath(sourceFile.fileName));
|
|
999
1009
|
bundled = false;
|
|
1000
1010
|
timeRecord = 0;
|
|
1001
1011
|
program = rebuildProgram();
|