vite-plugin-dts 1.0.1 → 1.0.2

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.js CHANGED
@@ -108,24 +108,25 @@ async function runParallel(maxConcurrency, source, iteratorFn) {
108
108
  }
109
109
  return Promise.all(ret);
110
110
  }
111
+ var speRE = /[\\/]/;
111
112
  function queryPublicPath(paths) {
112
113
  if (paths.length === 0) {
113
114
  return "";
114
115
  } else if (paths.length === 1) {
115
116
  return (0, import_path.dirname)(paths[0]);
116
117
  }
117
- let publicPath = (0, import_path.dirname)(paths[0]) + "\\";
118
- let publicUnits = publicPath.split(/[\\/]/);
118
+ let publicPath = (0, import_path.normalize)((0, import_path.dirname)(paths[0])) + import_path.sep;
119
+ let publicUnits = publicPath.split(speRE);
119
120
  let index2 = publicUnits.length - 1;
120
121
  for (const path of paths.slice(1)) {
121
122
  if (!index2) {
122
123
  return publicPath;
123
124
  }
124
- const dirPath = (0, import_path.dirname)(path) + "\\";
125
+ const dirPath = (0, import_path.normalize)((0, import_path.dirname)(path)) + import_path.sep;
125
126
  if (dirPath.startsWith(publicPath)) {
126
127
  continue;
127
128
  }
128
- const units = dirPath.split(/[\\/]/);
129
+ const units = dirPath.split(speRE);
129
130
  if (units.length < index2) {
130
131
  publicPath = dirPath;
131
132
  publicUnits = units;
@@ -138,7 +139,7 @@ function queryPublicPath(paths) {
138
139
  }
139
140
  index2 = i - 1;
140
141
  publicUnits = publicUnits.slice(0, index2 + 1);
141
- publicPath = publicUnits.join("\\") + "\\";
142
+ publicPath = publicUnits.join(import_path.sep) + import_path.sep;
142
143
  break;
143
144
  }
144
145
  }
@@ -485,6 +486,7 @@ ${import_chalk.default.cyan("[vite:dts]")} Start generate declaration files...`)
485
486
  if (!entryRoot) {
486
487
  entryRoot = queryPublicPath(outputFiles.map((file) => file.path));
487
488
  }
489
+ entryRoot = ensureAbsolute(entryRoot, root);
488
490
  bundleDebug("emit");
489
491
  await runParallel(import_os.default.cpus().length, outputFiles, async (outputFile) => {
490
492
  var _a3, _b2;
package/dist/index.mjs CHANGED
@@ -22,7 +22,7 @@ import { dirname as dirname2, relative, isAbsolute as isAbsolute2 } from "path";
22
22
  import { normalizePath } from "vite";
23
23
 
24
24
  // src/utils.ts
25
- import { resolve, isAbsolute, dirname } from "path";
25
+ import { resolve, isAbsolute, dirname, normalize, sep } from "path";
26
26
  function isNativeObj(value) {
27
27
  return Object.prototype.toString.call(value) === "[object Object]";
28
28
  }
@@ -87,24 +87,25 @@ async function runParallel(maxConcurrency, source, iteratorFn) {
87
87
  }
88
88
  return Promise.all(ret);
89
89
  }
90
+ var speRE = /[\\/]/;
90
91
  function queryPublicPath(paths) {
91
92
  if (paths.length === 0) {
92
93
  return "";
93
94
  } else if (paths.length === 1) {
94
95
  return dirname(paths[0]);
95
96
  }
96
- let publicPath = dirname(paths[0]) + "\\";
97
- let publicUnits = publicPath.split(/[\\/]/);
97
+ let publicPath = normalize(dirname(paths[0])) + sep;
98
+ let publicUnits = publicPath.split(speRE);
98
99
  let index2 = publicUnits.length - 1;
99
100
  for (const path of paths.slice(1)) {
100
101
  if (!index2) {
101
102
  return publicPath;
102
103
  }
103
- const dirPath = dirname(path) + "\\";
104
+ const dirPath = normalize(dirname(path)) + sep;
104
105
  if (dirPath.startsWith(publicPath)) {
105
106
  continue;
106
107
  }
107
- const units = dirPath.split(/[\\/]/);
108
+ const units = dirPath.split(speRE);
108
109
  if (units.length < index2) {
109
110
  publicPath = dirPath;
110
111
  publicUnits = units;
@@ -117,7 +118,7 @@ function queryPublicPath(paths) {
117
118
  }
118
119
  index2 = i - 1;
119
120
  publicUnits = publicUnits.slice(0, index2 + 1);
120
- publicPath = publicUnits.join("\\") + "\\";
121
+ publicPath = publicUnits.join(sep) + sep;
121
122
  break;
122
123
  }
123
124
  }
@@ -464,6 +465,7 @@ ${chalk.cyan("[vite:dts]")} Start generate declaration files...`));
464
465
  if (!entryRoot) {
465
466
  entryRoot = queryPublicPath(outputFiles.map((file) => file.path));
466
467
  }
468
+ entryRoot = ensureAbsolute(entryRoot, root);
467
469
  bundleDebug("emit");
468
470
  await runParallel(os.cpus().length, outputFiles, async (outputFile) => {
469
471
  var _a3, _b2;
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "test:e2e": "cd example && cross-env DEBUG=\"vite-plugin-dts:bundle\" vite build"
92
92
  },
93
93
  "types": "dist/index.d.ts",
94
- "version": "1.0.1"
94
+ "version": "1.0.2"
95
95
  }