vite-plugin-dts 3.3.0 → 3.3.1

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
@@ -167,6 +167,14 @@ function tryGetPkgPath(beginPath) {
167
167
  }
168
168
  return tryGetPkgPath(parentDir);
169
169
  }
170
+ function toCapitalCase(value) {
171
+ value = value.trim().replace(/\s+/g, "-");
172
+ value = value.replace(/-+(\w)/g, (_, char) => char ? char.toUpperCase() : "");
173
+ return (value.charAt(0).toLocaleUpperCase() + value.slice(1)).replace(
174
+ /[^\w]/g,
175
+ ""
176
+ );
177
+ }
170
178
 
171
179
  const dtsRE$1 = /\.d\.tsx?$/;
172
180
  function rollupDeclarationFiles({
@@ -196,7 +204,8 @@ function rollupDeclarationFiles({
196
204
  }
197
205
  },
198
206
  apiReport: {
199
- enabled: false
207
+ enabled: false,
208
+ reportFileName: "<unscopedPackageName>.api.md"
200
209
  },
201
210
  docModel: {
202
211
  enabled: false
@@ -610,7 +619,7 @@ ${kolorist.cyan(
610
619
  const rootNames = Object.values(entries).map((entry) => ensureAbsolute(entry, root)).concat(content?.fileNames.filter(filter) || []).map(normalizePath);
611
620
  host = ts__default.createCompilerHost(compilerOptions, true);
612
621
  program = vueTsc.createProgram({ host, rootNames, options: compilerOptions });
613
- libName = libName || "_default";
622
+ libName = toCapitalCase(libName || "_default");
614
623
  indexName = indexName || defaultIndex;
615
624
  const maybeEmitted = (sourceFile) => {
616
625
  return !(compilerOptions.noEmitForJsFiles && jsRE.test(sourceFile.fileName)) && !sourceFile.isDeclarationFile && !program.isSourceFileFromExternalLibrary(sourceFile);
@@ -693,7 +702,7 @@ ${kolorist.cyan(
693
702
  }
694
703
  },
695
704
  async writeBundle() {
696
- if (!program || bundled)
705
+ if (!host || !program || bundled)
697
706
  return;
698
707
  bundled = true;
699
708
  bundleDebug("begin writeBundle");
@@ -743,6 +752,7 @@ ${logPrefix} Start generate declaration files...`));
743
752
  }
744
753
  }
745
754
  bundleDebug("emit output patch");
755
+ const currentDir = host.getCurrentDirectory();
746
756
  await runParallel(
747
757
  node_os.cpus().length,
748
758
  Array.from(outputFiles.entries()),
@@ -763,7 +773,12 @@ ${logPrefix} Start generate declaration files...`));
763
773
  try {
764
774
  const sourceMap = JSON.parse(content);
765
775
  sourceMap.sources = sourceMap.sources.map((source) => {
766
- return normalizePath(node_path.relative(node_path.dirname(path), resolve(baseDir, source)));
776
+ return normalizePath(
777
+ node_path.relative(
778
+ node_path.dirname(path),
779
+ resolve(currentDir, node_path.relative(publicRoot, baseDir), source)
780
+ )
781
+ );
767
782
  });
768
783
  content = JSON.stringify(sourceMap);
769
784
  } catch (e) {
package/dist/index.mjs CHANGED
@@ -167,6 +167,14 @@ function tryGetPkgPath(beginPath) {
167
167
  }
168
168
  return tryGetPkgPath(parentDir);
169
169
  }
170
+ function toCapitalCase(value) {
171
+ value = value.trim().replace(/\s+/g, "-");
172
+ value = value.replace(/-+(\w)/g, (_, char) => char ? char.toUpperCase() : "");
173
+ return (value.charAt(0).toLocaleUpperCase() + value.slice(1)).replace(
174
+ /[^\w]/g,
175
+ ""
176
+ );
177
+ }
170
178
 
171
179
  const dtsRE$1 = /\.d\.tsx?$/;
172
180
  function rollupDeclarationFiles({
@@ -196,7 +204,8 @@ function rollupDeclarationFiles({
196
204
  }
197
205
  },
198
206
  apiReport: {
199
- enabled: false
207
+ enabled: false,
208
+ reportFileName: "<unscopedPackageName>.api.md"
200
209
  },
201
210
  docModel: {
202
211
  enabled: false
@@ -610,7 +619,7 @@ ${cyan(
610
619
  const rootNames = Object.values(entries).map((entry) => ensureAbsolute(entry, root)).concat(content?.fileNames.filter(filter) || []).map(normalizePath);
611
620
  host = ts.createCompilerHost(compilerOptions, true);
612
621
  program = createProgram({ host, rootNames, options: compilerOptions });
613
- libName = libName || "_default";
622
+ libName = toCapitalCase(libName || "_default");
614
623
  indexName = indexName || defaultIndex;
615
624
  const maybeEmitted = (sourceFile) => {
616
625
  return !(compilerOptions.noEmitForJsFiles && jsRE.test(sourceFile.fileName)) && !sourceFile.isDeclarationFile && !program.isSourceFileFromExternalLibrary(sourceFile);
@@ -693,7 +702,7 @@ ${cyan(
693
702
  }
694
703
  },
695
704
  async writeBundle() {
696
- if (!program || bundled)
705
+ if (!host || !program || bundled)
697
706
  return;
698
707
  bundled = true;
699
708
  bundleDebug("begin writeBundle");
@@ -743,6 +752,7 @@ ${logPrefix} Start generate declaration files...`));
743
752
  }
744
753
  }
745
754
  bundleDebug("emit output patch");
755
+ const currentDir = host.getCurrentDirectory();
746
756
  await runParallel(
747
757
  cpus().length,
748
758
  Array.from(outputFiles.entries()),
@@ -763,7 +773,12 @@ ${logPrefix} Start generate declaration files...`));
763
773
  try {
764
774
  const sourceMap = JSON.parse(content);
765
775
  sourceMap.sources = sourceMap.sources.map((source) => {
766
- return normalizePath(relative(dirname(path), resolve(baseDir, source)));
776
+ return normalizePath(
777
+ relative(
778
+ dirname(path),
779
+ resolve(currentDir, relative(publicRoot, baseDir), source)
780
+ )
781
+ );
767
782
  });
768
783
  content = JSON.stringify(sourceMap);
769
784
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "qmhc",