vite-plugin-dts 4.4.0 → 4.5.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.
Files changed (3) hide show
  1. package/dist/index.cjs +40 -53
  2. package/dist/index.mjs +39 -52
  3. package/package.json +36 -40
package/dist/index.cjs CHANGED
@@ -198,7 +198,7 @@ function tryGetPkgPath(beginPath) {
198
198
  }
199
199
  const parentDir = normalizePath(node_path.dirname(beginPath));
200
200
  if (!parentDir || parentDir === beginPath) {
201
- pkgPathCache.set(beginPath, void 0);
201
+ pkgPathCache.set(beginPath, undefined);
202
202
  return;
203
203
  }
204
204
  return tryGetPkgPath(parentDir);
@@ -214,16 +214,13 @@ function toCapitalCase(value) {
214
214
  function findTypesPath(...pkgs) {
215
215
  let path;
216
216
  for (const pkg of pkgs) {
217
- if (typeof pkg !== "object")
218
- continue;
217
+ if (typeof pkg !== "object") continue;
219
218
  path = pkg.types || pkg.typings || pkg.exports?.types || pkg.exports?.["."]?.types || pkg.exports?.["./"]?.types;
220
- if (path)
221
- return path;
219
+ if (path) return path;
222
220
  }
223
221
  }
224
222
  function setModuleResolution(options) {
225
- if (options.moduleResolution)
226
- return;
223
+ if (options.moduleResolution) return;
227
224
  const module = typeof options.module === "number" ? options.module : options.target ?? ts__default.ScriptTarget.ES5 >= 2 ? ts__default.ModuleKind.ES2015 : ts__default.ModuleKind.CommonJS;
228
225
  let moduleResolution;
229
226
  switch (module) {
@@ -310,7 +307,7 @@ function importResolves(path) {
310
307
  }
311
308
  function tryGetPackageInfo(name) {
312
309
  if (process.versions.pnp) {
313
- const targetRequire = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
310
+ const targetRequire = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
314
311
  try {
315
312
  return localPkg.getPackageInfoSync(
316
313
  targetRequire.resolve(`${name}/package.json`, { paths: [process.cwd()] })
@@ -420,8 +417,7 @@ function JsonResolver() {
420
417
  },
421
418
  transform({ id, root, program }) {
422
419
  const sourceFile = program.getSourceFile(id);
423
- if (!sourceFile)
424
- return [];
420
+ if (!sourceFile) return [];
425
421
  return [
426
422
  {
427
423
  path: node_path.relative(root, `${id}.d.ts`),
@@ -438,8 +434,7 @@ export default _default;
438
434
  const svelteRE = /\.svelte$/;
439
435
  let lowerVersion;
440
436
  function querySvelteVersion() {
441
- if (typeof lowerVersion === "boolean")
442
- return;
437
+ if (typeof lowerVersion === "boolean") return;
443
438
  try {
444
439
  const version = tryGetPackageInfo("svelte")?.version;
445
440
  lowerVersion = version ? compareVersions.compare(version, "4.0.0", "<") : false;
@@ -475,19 +470,17 @@ function VueResolver() {
475
470
  },
476
471
  transform({ id, code, program }) {
477
472
  const sourceFile = program.getSourceFile(id) || program.getSourceFile(id + ".ts") || program.getSourceFile(id + ".js") || program.getSourceFile(id + ".tsx") || program.getSourceFile(id + ".jsx");
478
- if (!sourceFile)
479
- return [];
473
+ if (!sourceFile) return [];
480
474
  const outputs = [];
481
475
  program.emit(
482
476
  sourceFile,
483
477
  (path, content) => {
484
478
  outputs.push({ path, content });
485
479
  },
486
- void 0,
480
+ undefined,
487
481
  true
488
482
  );
489
- if (!program.getCompilerOptions().declarationMap)
490
- return outputs;
483
+ if (!program.getCompilerOptions().declarationMap) return outputs;
491
484
  const [beforeScript] = code.split(/\s*<script.*>/);
492
485
  const beforeLines = beforeScript.split("\n").length;
493
486
  for (const output of outputs) {
@@ -536,16 +529,13 @@ function walkSourceFile(sourceFile, callback) {
536
529
  sourceFile.forEachChild((child) => walkNode(child, sourceFile, callback));
537
530
  }
538
531
  function isAliasMatch(alias, importer) {
539
- if (isRegExp(alias.find))
540
- return alias.find.test(importer);
541
- if (importer.length < alias.find.length)
542
- return false;
543
- if (importer === alias.find)
544
- return true;
532
+ if (isRegExp(alias.find)) return alias.find.test(importer);
533
+ if (importer.length < alias.find.length) return false;
534
+ if (importer === alias.find) return true;
545
535
  return importer.indexOf(alias.find) === 0 && (alias.find.endsWith("/") || importer.substring(alias.find.length)[0] === "/");
546
536
  }
547
537
  function transformAlias(importer, dir, aliases, aliasesExclude) {
548
- if (aliases.length && !aliasesExclude.some((e) => isRegExp(e) ? e.test(importer) : String(e) === importer)) {
538
+ if (aliases?.length && !aliasesExclude.some((e) => isRegExp(e) ? e.test(importer) : String(e) === importer)) {
549
539
  const matchedAlias = aliases.find((alias) => isAliasMatch(alias, importer));
550
540
  if (matchedAlias) {
551
541
  const replacement = node_path.isAbsolute(matchedAlias.replacement) ? normalizePath(node_path.relative(dir, matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
@@ -557,10 +547,8 @@ function transformAlias(importer, dir, aliases, aliasesExclude) {
557
547
  const absolutePath = node_path.resolve(dir, truthPath);
558
548
  const normalizedPath = normalizePath(node_path.relative(dir, absolutePath));
559
549
  const resultPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
560
- if (!isAliasGlobal(matchedAlias))
561
- return resultPath;
562
- if (importResolves(absolutePath))
563
- return resultPath;
550
+ if (!isAliasGlobal(matchedAlias)) return resultPath;
551
+ if (importResolves(absolutePath)) return resultPath;
564
552
  }
565
553
  }
566
554
  return importer;
@@ -609,7 +597,7 @@ function transformCode(options) {
609
597
  if (node.importClause.namedBindings && ts__default.isNamedImports(node.importClause.namedBindings)) {
610
598
  node.importClause.namedBindings.elements.forEach((element) => {
611
599
  if (element.propertyName) {
612
- importSet.add(`${element.propertyName.escapedText} as ${element.name.escapedText}`);
600
+ importSet.add(`${element.propertyName.getText(ast)} as ${element.name.escapedText}`);
613
601
  } else {
614
602
  importSet.add(element.name.escapedText);
615
603
  }
@@ -661,10 +649,16 @@ function transformCode(options) {
661
649
  if (ts__default.isModuleDeclaration(node) && node.body && ts__default.isModuleBlock(node.body)) {
662
650
  if (ts__default.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
663
651
  s.remove(node.pos, node.end);
664
- } else if (node.modifiers?.[0] && node.modifiers[0].kind === ts__default.SyntaxKind.DeclareKeyword && !node.body.statements.some(
665
- (s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
666
- )) {
667
- declareModules.push(s.slice(node.pos, node.end + 1));
652
+ } else if (ts__default.isStringLiteral(node.name)) {
653
+ const libName = toLibName(node.name.text);
654
+ if (libName !== node.name.text) {
655
+ s.update(node.name.pos, node.name.end, ` '${libName}'`);
656
+ }
657
+ if (!libName.startsWith(".") && node.modifiers?.[0] && node.modifiers[0].kind === ts__default.SyntaxKind.DeclareKeyword && !node.body.statements.some(
658
+ (s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
659
+ )) {
660
+ declareModules.push(s.slice(node.pos, node.end + 1));
661
+ }
668
662
  }
669
663
  return false;
670
664
  }
@@ -688,7 +682,7 @@ function hasNormalExport(content) {
688
682
  if (ts__default.isExportDeclaration(node)) {
689
683
  if (node.exportClause && ts__default.isNamedExports(node.exportClause)) {
690
684
  for (const element of node.exportClause.elements) {
691
- if (element.name.escapedText !== "default") {
685
+ if (element.name.getText(ast) !== "default") {
692
686
  has = true;
693
687
  break;
694
688
  }
@@ -716,7 +710,7 @@ function hasExportDefault(content) {
716
710
  has = true;
717
711
  } else if (ts__default.isExportDeclaration(node) && node.exportClause && ts__default.isNamedExports(node.exportClause)) {
718
712
  for (const element of node.exportClause.elements) {
719
- if (element.name.escapedText === "default") {
713
+ if (element.name.getText(ast) === "default") {
720
714
  has = true;
721
715
  break;
722
716
  }
@@ -749,11 +743,10 @@ const fixedCompilerOptions = {
749
743
  noEmit: false,
750
744
  declaration: true,
751
745
  emitDeclarationOnly: true,
752
- noUnusedParameters: false,
753
746
  checkJs: false,
754
747
  skipLibCheck: true,
755
748
  preserveSymlinks: false,
756
- noEmitOnError: void 0,
749
+ noEmitOnError: undefined,
757
750
  target: ts__default.ScriptTarget.ESNext
758
751
  };
759
752
  const noop = () => {
@@ -883,8 +876,7 @@ ${logPrefix} ${kolorist.yellow(
883
876
  bundleDebug("parse vite config");
884
877
  },
885
878
  options(options2) {
886
- if (entries)
887
- return;
879
+ if (entries) return;
888
880
  const input = typeof options2.input === "string" ? [options2.input] : options2.input;
889
881
  if (Array.isArray(input)) {
890
882
  entries = input.reduce(
@@ -904,13 +896,12 @@ ${logPrefix} ${kolorist.yellow(
904
896
  bundleDebug("parse options");
905
897
  },
906
898
  async buildStart() {
907
- if (program)
908
- return;
899
+ if (program) return;
909
900
  bundleDebug("begin buildStart");
910
901
  timeRecord = 0;
911
902
  const startTime = Date.now();
912
903
  configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts__default.findConfigFile(root, ts__default.sys.fileExists);
913
- const content = configPath ? languageCore.createParsedCommandLine(ts__default, ts__default.sys, configPath) : void 0;
904
+ const content = configPath ? languageCore.createParsedCommandLine(ts__default, ts__default.sys, configPath) : undefined;
914
905
  compilerOptions = {
915
906
  ...content?.options || {},
916
907
  ...options.compilerOptions || {},
@@ -934,7 +925,7 @@ ${logPrefix} ${kolorist.yellow(
934
925
  // Here we are using the default value to set the `baseUrl` to the current directory if no value exists. This is
935
926
  // the same behavior as the TS Compiler. See TS source:
936
927
  // https://github.com/microsoft/TypeScript/blob/3386e943215613c40f68ba0b108cda1ddb7faee1/src/compiler/utilities.ts#L6493-L6501
937
- baseUrl = compilerOptions.paths ? process.cwd() : void 0,
928
+ baseUrl = compilerOptions.paths ? process.cwd() : undefined,
938
929
  paths
939
930
  } = compilerOptions;
940
931
  if (pathsToAliases && baseUrl && paths) {
@@ -1044,7 +1035,7 @@ ${logPrefix} ${kolorist.yellow(
1044
1035
  text
1045
1036
  );
1046
1037
  },
1047
- void 0,
1038
+ undefined,
1048
1039
  true
1049
1040
  );
1050
1041
  }
@@ -1073,8 +1064,7 @@ ${logPrefix} ${kolorist.yellow(
1073
1064
  },
1074
1065
  async writeBundle() {
1075
1066
  transformedFiles.clear();
1076
- if (!host || !program || bundled)
1077
- return;
1067
+ if (!host || !program || bundled) return;
1078
1068
  bundled = true;
1079
1069
  bundleDebug("begin writeBundle");
1080
1070
  logger.info(kolorist.green(`
@@ -1086,8 +1076,7 @@ ${logPrefix} Start generate declaration files...`));
1086
1076
  const writeOutput = async (path, content, outDir2, record = true) => {
1087
1077
  if (typeof beforeWriteFile === "function") {
1088
1078
  const result = await unwrapPromise(beforeWriteFile(path, content));
1089
- if (result === false)
1090
- return;
1079
+ if (result === false) return;
1091
1080
  if (result) {
1092
1081
  path = result.filePath || path;
1093
1082
  content = result.content ?? content;
@@ -1107,8 +1096,7 @@ ${logPrefix} Start generate declaration files...`));
1107
1096
  };
1108
1097
  const sourceFiles = program.getSourceFiles();
1109
1098
  for (const sourceFile of sourceFiles) {
1110
- if (!filter(sourceFile.fileName))
1111
- continue;
1099
+ if (!filter(sourceFile.fileName)) continue;
1112
1100
  if (copyDtsFiles && dtsRE.test(sourceFile.fileName)) {
1113
1101
  setOutputFile(normalizePath(sourceFile.fileName), sourceFile.getFullText());
1114
1102
  }
@@ -1121,7 +1109,7 @@ ${logPrefix} Start generate declaration files...`));
1121
1109
  text
1122
1110
  );
1123
1111
  },
1124
- void 0,
1112
+ undefined,
1125
1113
  true
1126
1114
  );
1127
1115
  rootFiles.delete(sourceFile.fileName);
@@ -1228,8 +1216,7 @@ ${logPrefix} ${kolorist.yellow(
1228
1216
  }
1229
1217
  for (const name of entryNames) {
1230
1218
  const entryDtsPath = multiple ? cleanPath(resolve(outDir, tsToDts(name)), emittedFiles) : typesPath;
1231
- if (node_fs.existsSync(entryDtsPath))
1232
- continue;
1219
+ if (node_fs.existsSync(entryDtsPath)) continue;
1233
1220
  const sourceEntry = normalizePath(
1234
1221
  cleanPath(resolve(outDir, node_path.relative(entryRoot, tsToDts(entries[name]))), emittedFiles)
1235
1222
  );
package/dist/index.mjs CHANGED
@@ -194,7 +194,7 @@ function tryGetPkgPath(beginPath) {
194
194
  }
195
195
  const parentDir = normalizePath(dirname(beginPath));
196
196
  if (!parentDir || parentDir === beginPath) {
197
- pkgPathCache.set(beginPath, void 0);
197
+ pkgPathCache.set(beginPath, undefined);
198
198
  return;
199
199
  }
200
200
  return tryGetPkgPath(parentDir);
@@ -210,16 +210,13 @@ function toCapitalCase(value) {
210
210
  function findTypesPath(...pkgs) {
211
211
  let path;
212
212
  for (const pkg of pkgs) {
213
- if (typeof pkg !== "object")
214
- continue;
213
+ if (typeof pkg !== "object") continue;
215
214
  path = pkg.types || pkg.typings || pkg.exports?.types || pkg.exports?.["."]?.types || pkg.exports?.["./"]?.types;
216
- if (path)
217
- return path;
215
+ if (path) return path;
218
216
  }
219
217
  }
220
218
  function setModuleResolution(options) {
221
- if (options.moduleResolution)
222
- return;
219
+ if (options.moduleResolution) return;
223
220
  const module = typeof options.module === "number" ? options.module : options.target ?? ts.ScriptTarget.ES5 >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
224
221
  let moduleResolution;
225
222
  switch (module) {
@@ -416,8 +413,7 @@ function JsonResolver() {
416
413
  },
417
414
  transform({ id, root, program }) {
418
415
  const sourceFile = program.getSourceFile(id);
419
- if (!sourceFile)
420
- return [];
416
+ if (!sourceFile) return [];
421
417
  return [
422
418
  {
423
419
  path: relative(root, `${id}.d.ts`),
@@ -434,8 +430,7 @@ export default _default;
434
430
  const svelteRE = /\.svelte$/;
435
431
  let lowerVersion;
436
432
  function querySvelteVersion() {
437
- if (typeof lowerVersion === "boolean")
438
- return;
433
+ if (typeof lowerVersion === "boolean") return;
439
434
  try {
440
435
  const version = tryGetPackageInfo("svelte")?.version;
441
436
  lowerVersion = version ? compare(version, "4.0.0", "<") : false;
@@ -471,19 +466,17 @@ function VueResolver() {
471
466
  },
472
467
  transform({ id, code, program }) {
473
468
  const sourceFile = program.getSourceFile(id) || program.getSourceFile(id + ".ts") || program.getSourceFile(id + ".js") || program.getSourceFile(id + ".tsx") || program.getSourceFile(id + ".jsx");
474
- if (!sourceFile)
475
- return [];
469
+ if (!sourceFile) return [];
476
470
  const outputs = [];
477
471
  program.emit(
478
472
  sourceFile,
479
473
  (path, content) => {
480
474
  outputs.push({ path, content });
481
475
  },
482
- void 0,
476
+ undefined,
483
477
  true
484
478
  );
485
- if (!program.getCompilerOptions().declarationMap)
486
- return outputs;
479
+ if (!program.getCompilerOptions().declarationMap) return outputs;
487
480
  const [beforeScript] = code.split(/\s*<script.*>/);
488
481
  const beforeLines = beforeScript.split("\n").length;
489
482
  for (const output of outputs) {
@@ -532,16 +525,13 @@ function walkSourceFile(sourceFile, callback) {
532
525
  sourceFile.forEachChild((child) => walkNode(child, sourceFile, callback));
533
526
  }
534
527
  function isAliasMatch(alias, importer) {
535
- if (isRegExp(alias.find))
536
- return alias.find.test(importer);
537
- if (importer.length < alias.find.length)
538
- return false;
539
- if (importer === alias.find)
540
- return true;
528
+ if (isRegExp(alias.find)) return alias.find.test(importer);
529
+ if (importer.length < alias.find.length) return false;
530
+ if (importer === alias.find) return true;
541
531
  return importer.indexOf(alias.find) === 0 && (alias.find.endsWith("/") || importer.substring(alias.find.length)[0] === "/");
542
532
  }
543
533
  function transformAlias(importer, dir, aliases, aliasesExclude) {
544
- if (aliases.length && !aliasesExclude.some((e) => isRegExp(e) ? e.test(importer) : String(e) === importer)) {
534
+ if (aliases?.length && !aliasesExclude.some((e) => isRegExp(e) ? e.test(importer) : String(e) === importer)) {
545
535
  const matchedAlias = aliases.find((alias) => isAliasMatch(alias, importer));
546
536
  if (matchedAlias) {
547
537
  const replacement = isAbsolute(matchedAlias.replacement) ? normalizePath(relative(dir, matchedAlias.replacement)) : normalizePath(matchedAlias.replacement);
@@ -553,10 +543,8 @@ function transformAlias(importer, dir, aliases, aliasesExclude) {
553
543
  const absolutePath = resolve$1(dir, truthPath);
554
544
  const normalizedPath = normalizePath(relative(dir, absolutePath));
555
545
  const resultPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
556
- if (!isAliasGlobal(matchedAlias))
557
- return resultPath;
558
- if (importResolves(absolutePath))
559
- return resultPath;
546
+ if (!isAliasGlobal(matchedAlias)) return resultPath;
547
+ if (importResolves(absolutePath)) return resultPath;
560
548
  }
561
549
  }
562
550
  return importer;
@@ -605,7 +593,7 @@ function transformCode(options) {
605
593
  if (node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) {
606
594
  node.importClause.namedBindings.elements.forEach((element) => {
607
595
  if (element.propertyName) {
608
- importSet.add(`${element.propertyName.escapedText} as ${element.name.escapedText}`);
596
+ importSet.add(`${element.propertyName.getText(ast)} as ${element.name.escapedText}`);
609
597
  } else {
610
598
  importSet.add(element.name.escapedText);
611
599
  }
@@ -657,10 +645,16 @@ function transformCode(options) {
657
645
  if (ts.isModuleDeclaration(node) && node.body && ts.isModuleBlock(node.body)) {
658
646
  if (ts.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
659
647
  s.remove(node.pos, node.end);
660
- } else if (node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && !node.body.statements.some(
661
- (s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
662
- )) {
663
- declareModules.push(s.slice(node.pos, node.end + 1));
648
+ } else if (ts.isStringLiteral(node.name)) {
649
+ const libName = toLibName(node.name.text);
650
+ if (libName !== node.name.text) {
651
+ s.update(node.name.pos, node.name.end, ` '${libName}'`);
652
+ }
653
+ if (!libName.startsWith(".") && node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && !node.body.statements.some(
654
+ (s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
655
+ )) {
656
+ declareModules.push(s.slice(node.pos, node.end + 1));
657
+ }
664
658
  }
665
659
  return false;
666
660
  }
@@ -684,7 +678,7 @@ function hasNormalExport(content) {
684
678
  if (ts.isExportDeclaration(node)) {
685
679
  if (node.exportClause && ts.isNamedExports(node.exportClause)) {
686
680
  for (const element of node.exportClause.elements) {
687
- if (element.name.escapedText !== "default") {
681
+ if (element.name.getText(ast) !== "default") {
688
682
  has = true;
689
683
  break;
690
684
  }
@@ -712,7 +706,7 @@ function hasExportDefault(content) {
712
706
  has = true;
713
707
  } else if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
714
708
  for (const element of node.exportClause.elements) {
715
- if (element.name.escapedText === "default") {
709
+ if (element.name.getText(ast) === "default") {
716
710
  has = true;
717
711
  break;
718
712
  }
@@ -745,11 +739,10 @@ const fixedCompilerOptions = {
745
739
  noEmit: false,
746
740
  declaration: true,
747
741
  emitDeclarationOnly: true,
748
- noUnusedParameters: false,
749
742
  checkJs: false,
750
743
  skipLibCheck: true,
751
744
  preserveSymlinks: false,
752
- noEmitOnError: void 0,
745
+ noEmitOnError: undefined,
753
746
  target: ts.ScriptTarget.ESNext
754
747
  };
755
748
  const noop = () => {
@@ -879,8 +872,7 @@ ${logPrefix} ${yellow(
879
872
  bundleDebug("parse vite config");
880
873
  },
881
874
  options(options2) {
882
- if (entries)
883
- return;
875
+ if (entries) return;
884
876
  const input = typeof options2.input === "string" ? [options2.input] : options2.input;
885
877
  if (Array.isArray(input)) {
886
878
  entries = input.reduce(
@@ -900,13 +892,12 @@ ${logPrefix} ${yellow(
900
892
  bundleDebug("parse options");
901
893
  },
902
894
  async buildStart() {
903
- if (program)
904
- return;
895
+ if (program) return;
905
896
  bundleDebug("begin buildStart");
906
897
  timeRecord = 0;
907
898
  const startTime = Date.now();
908
899
  configPath = tsconfigPath ? ensureAbsolute(tsconfigPath, root) : ts.findConfigFile(root, ts.sys.fileExists);
909
- const content = configPath ? createParsedCommandLine(ts, ts.sys, configPath) : void 0;
900
+ const content = configPath ? createParsedCommandLine(ts, ts.sys, configPath) : undefined;
910
901
  compilerOptions = {
911
902
  ...content?.options || {},
912
903
  ...options.compilerOptions || {},
@@ -930,7 +921,7 @@ ${logPrefix} ${yellow(
930
921
  // Here we are using the default value to set the `baseUrl` to the current directory if no value exists. This is
931
922
  // the same behavior as the TS Compiler. See TS source:
932
923
  // https://github.com/microsoft/TypeScript/blob/3386e943215613c40f68ba0b108cda1ddb7faee1/src/compiler/utilities.ts#L6493-L6501
933
- baseUrl = compilerOptions.paths ? process.cwd() : void 0,
924
+ baseUrl = compilerOptions.paths ? process.cwd() : undefined,
934
925
  paths
935
926
  } = compilerOptions;
936
927
  if (pathsToAliases && baseUrl && paths) {
@@ -1040,7 +1031,7 @@ ${logPrefix} ${yellow(
1040
1031
  text
1041
1032
  );
1042
1033
  },
1043
- void 0,
1034
+ undefined,
1044
1035
  true
1045
1036
  );
1046
1037
  }
@@ -1069,8 +1060,7 @@ ${logPrefix} ${yellow(
1069
1060
  },
1070
1061
  async writeBundle() {
1071
1062
  transformedFiles.clear();
1072
- if (!host || !program || bundled)
1073
- return;
1063
+ if (!host || !program || bundled) return;
1074
1064
  bundled = true;
1075
1065
  bundleDebug("begin writeBundle");
1076
1066
  logger.info(green(`
@@ -1082,8 +1072,7 @@ ${logPrefix} Start generate declaration files...`));
1082
1072
  const writeOutput = async (path, content, outDir2, record = true) => {
1083
1073
  if (typeof beforeWriteFile === "function") {
1084
1074
  const result = await unwrapPromise(beforeWriteFile(path, content));
1085
- if (result === false)
1086
- return;
1075
+ if (result === false) return;
1087
1076
  if (result) {
1088
1077
  path = result.filePath || path;
1089
1078
  content = result.content ?? content;
@@ -1103,8 +1092,7 @@ ${logPrefix} Start generate declaration files...`));
1103
1092
  };
1104
1093
  const sourceFiles = program.getSourceFiles();
1105
1094
  for (const sourceFile of sourceFiles) {
1106
- if (!filter(sourceFile.fileName))
1107
- continue;
1095
+ if (!filter(sourceFile.fileName)) continue;
1108
1096
  if (copyDtsFiles && dtsRE.test(sourceFile.fileName)) {
1109
1097
  setOutputFile(normalizePath(sourceFile.fileName), sourceFile.getFullText());
1110
1098
  }
@@ -1117,7 +1105,7 @@ ${logPrefix} Start generate declaration files...`));
1117
1105
  text
1118
1106
  );
1119
1107
  },
1120
- void 0,
1108
+ undefined,
1121
1109
  true
1122
1110
  );
1123
1111
  rootFiles.delete(sourceFile.fileName);
@@ -1224,8 +1212,7 @@ ${logPrefix} ${yellow(
1224
1212
  }
1225
1213
  for (const name of entryNames) {
1226
1214
  const entryDtsPath = multiple ? cleanPath(resolve(outDir, tsToDts(name)), emittedFiles) : typesPath;
1227
- if (existsSync(entryDtsPath))
1228
- continue;
1215
+ if (existsSync(entryDtsPath)) continue;
1229
1216
  const sourceEntry = normalizePath(
1230
1217
  cleanPath(resolve(outDir, relative(entryRoot, tsToDts(entries[name]))), emittedFiles)
1231
1218
  );
package/package.json CHANGED
@@ -1,28 +1,9 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "type": "module",
5
- "packageManager": "pnpm@9.13.2",
6
5
  "license": "MIT",
7
6
  "author": "qmhc",
8
- "scripts": {
9
- "build": "tsx scripts/build.ts",
10
- "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
11
- "dev": "unbuild --stub",
12
- "_postinstall": "is-ci || husky install",
13
- "lint": "eslint --ext .js,.jsx,.ts,.tsx \"{src,tests}/**\"",
14
- "precommit": "lint-staged -c ./.husky/.lintstagedrc -q --allow-empty",
15
- "prepublishOnly": "pinst --disable",
16
- "prettier": "pretty-quick --staged && pnpm run lint",
17
- "postpublish": "pinst --enable",
18
- "release": "tsx scripts/release.ts",
19
- "test": "vitest run",
20
- "test:dev": "vitest",
21
- "test:react": "pnpm -C examples/react build",
22
- "test:svelte": "pnpm -C examples/svelte build",
23
- "test:ts": "pnpm -C examples/ts build",
24
- "test:vue": "pnpm -C examples/vue build"
25
- },
26
7
  "main": "dist/index.cjs",
27
8
  "module": "dist/index.mjs",
28
9
  "types": "dist/index.d.ts",
@@ -36,9 +17,6 @@
36
17
  "files": [
37
18
  "dist"
38
19
  ],
39
- "engines": {
40
- "node": "^14.18.0 || >=16.0.0"
41
- },
42
20
  "keywords": [
43
21
  "vite",
44
22
  "vite-plugin",
@@ -58,46 +36,47 @@
58
36
  "url": "https://github.com/qmhc/vite-plugin-dts/issues"
59
37
  },
60
38
  "dependencies": {
61
- "@microsoft/api-extractor": "^7.48.1",
39
+ "@microsoft/api-extractor": "^7.50.1",
62
40
  "@rollup/pluginutils": "^5.1.4",
63
41
  "@volar/typescript": "^2.4.11",
64
- "@vue/language-core": "2.1.10",
42
+ "@vue/language-core": "2.2.4",
65
43
  "compare-versions": "^6.1.1",
66
44
  "debug": "^4.4.0",
67
45
  "kolorist": "^1.8.0",
68
- "local-pkg": "^0.5.1",
46
+ "local-pkg": "^1.0.0",
69
47
  "magic-string": "^0.30.17"
70
48
  },
71
49
  "devDependencies": {
72
- "@commitlint/cli": "^19.5.0",
50
+ "@commitlint/cli": "^19.7.1",
73
51
  "@types/debug": "^4.1.12",
74
52
  "@types/minimist": "^1.2.5",
75
- "@types/node": "^22.9.0",
53
+ "@types/node": "^22.13.5",
76
54
  "@types/prompts": "^2.4.9",
77
55
  "@types/semver": "^7.5.8",
78
56
  "@vexip-ui/commitlint-config": "^0.5.0",
79
57
  "@vexip-ui/eslint-config": "^0.12.1",
80
58
  "@vexip-ui/prettier-config": "^1.0.0",
59
+ "@vexip-ui/scripts": "^1.2.0",
81
60
  "@vue/eslint-config-standard": "^8.0.1",
82
61
  "@vue/eslint-config-typescript": "^13.0.0",
83
62
  "conventional-changelog-cli": "^5.0.0",
84
63
  "eslint": "^8.57.0",
85
- "execa": "^8.0.1",
86
- "husky": "^8.0.3",
87
- "is-ci": "^3.0.1",
88
- "lint-staged": "^15.2.10",
64
+ "execa": "^9.5.2",
65
+ "husky": "^9.1.7",
66
+ "is-ci": "^4.1.0",
67
+ "lint-staged": "^15.4.3",
89
68
  "minimist": "^1.2.8",
90
69
  "pinst": "^3.0.0",
91
- "prettier": "^3.3.3",
70
+ "prettier": "^3.5.2",
92
71
  "pretty-quick": "^4.0.0",
93
72
  "prompts": "^2.4.2",
94
73
  "rimraf": "^6.0.1",
95
- "semver": "^7.6.3",
96
- "tsx": "^4.19.2",
97
- "typescript": "5.6.3",
98
- "unbuild": "^2.0.0",
99
- "vite": "^5.4.11",
100
- "vitest": "^2.1.5"
74
+ "semver": "^7.7.1",
75
+ "tsx": "^4.19.3",
76
+ "typescript": "5.7.3",
77
+ "unbuild": "^3.3.1",
78
+ "vite": "^6.2.0",
79
+ "vitest": "^3.0.7"
101
80
  },
102
81
  "peerDependencies": {
103
82
  "typescript": "*",
@@ -107,5 +86,22 @@
107
86
  "vite": {
108
87
  "optional": true
109
88
  }
89
+ },
90
+ "scripts": {
91
+ "build": "tsx scripts/build.ts",
92
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
93
+ "dev": "unbuild --stub",
94
+ "_postinstall": "is-ci || husky install",
95
+ "lint": "eslint --ext .js,.jsx,.ts,.tsx \"{src,tests}/**\"",
96
+ "precommit": "lint-staged -c ./.husky/.lintstagedrc -q --allow-empty",
97
+ "prettier": "pretty-quick --staged && pnpm run lint",
98
+ "publish:ci": "tsx scripts/publish.ts",
99
+ "release": "tsx scripts/release.ts",
100
+ "test": "vitest run",
101
+ "test:dev": "vitest",
102
+ "test:react": "pnpm -C examples/react build",
103
+ "test:svelte": "pnpm -C examples/svelte build",
104
+ "test:ts": "pnpm -C examples/ts build",
105
+ "test:vue": "pnpm -C examples/vue build"
110
106
  }
111
- }
107
+ }