vite-plugin-dts 4.2.3 → 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/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({
@@ -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 { baseUrl, paths } = compilerOptions;
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
- const rootNames = [
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
- rootNames.forEach((file) => {
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
- rootFiles.add(sourceFile.fileName);
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({
@@ -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 { baseUrl, paths } = compilerOptions;
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
- const rootNames = [
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
- rootNames.forEach((file) => {
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
- rootFiles.add(sourceFile.fileName);
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "4.2.3",
3
+ "version": "4.2.4",
4
4
  "type": "module",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "license": "MIT",