vite-plugin-dts 3.8.1 → 3.8.3

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
@@ -497,7 +497,7 @@ function transformCode(options) {
497
497
  );
498
498
  if (!options.staticImport) {
499
499
  s.update(node.argument.literal.pos, node.argument.literal.end, `'${libName}'`);
500
- return false;
500
+ return !!node.typeArguments;
501
501
  }
502
502
  const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
503
503
  let usedType = node.qualifier.escapedText;
@@ -536,7 +536,12 @@ function transformCode(options) {
536
536
  return false;
537
537
  }
538
538
  if (ts__default.isModuleDeclaration(node)) {
539
- declareModules.push(s.slice(node.pos, node.end + 1));
539
+ if (node.body && ts__default.isModuleBlock(node.body) && !node.body.statements.some(
540
+ (s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
541
+ )) {
542
+ declareModules.push(s.slice(node.pos, node.end + 1));
543
+ }
544
+ return false;
540
545
  }
541
546
  });
542
547
  importMap.forEach((importSet, libName) => {
@@ -558,6 +563,14 @@ function hasExportDefault(content) {
558
563
  for (const element of node.exportClause.elements) {
559
564
  if (element.name.escapedText === "default") {
560
565
  has = true;
566
+ break;
567
+ }
568
+ }
569
+ } else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
570
+ for (let i = 0, len = node.modifiers.length; i < len; ++i) {
571
+ if (node.modifiers[i].kind === ts__default.SyntaxKind.ExportKeyword && node.modifiers[i + 1]?.kind === ts__default.SyntaxKind.DefaultKeyword) {
572
+ has = true;
573
+ break;
561
574
  }
562
575
  }
563
576
  }
package/dist/index.mjs CHANGED
@@ -494,7 +494,7 @@ function transformCode(options) {
494
494
  );
495
495
  if (!options.staticImport) {
496
496
  s.update(node.argument.literal.pos, node.argument.literal.end, `'${libName}'`);
497
- return false;
497
+ return !!node.typeArguments;
498
498
  }
499
499
  const importSet = importMap.get(libName) ?? importMap.set(libName, /* @__PURE__ */ new Set()).get(libName);
500
500
  let usedType = node.qualifier.escapedText;
@@ -533,7 +533,12 @@ function transformCode(options) {
533
533
  return false;
534
534
  }
535
535
  if (ts.isModuleDeclaration(node)) {
536
- declareModules.push(s.slice(node.pos, node.end + 1));
536
+ if (node.body && ts.isModuleBlock(node.body) && !node.body.statements.some(
537
+ (s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
538
+ )) {
539
+ declareModules.push(s.slice(node.pos, node.end + 1));
540
+ }
541
+ return false;
537
542
  }
538
543
  });
539
544
  importMap.forEach((importSet, libName) => {
@@ -555,6 +560,14 @@ function hasExportDefault(content) {
555
560
  for (const element of node.exportClause.elements) {
556
561
  if (element.name.escapedText === "default") {
557
562
  has = true;
563
+ break;
564
+ }
565
+ }
566
+ } else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
567
+ for (let i = 0, len = node.modifiers.length; i < len; ++i) {
568
+ if (node.modifiers[i].kind === ts.SyntaxKind.ExportKeyword && node.modifiers[i + 1]?.kind === ts.SyntaxKind.DefaultKeyword) {
569
+ has = true;
570
+ break;
558
571
  }
559
572
  }
560
573
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "3.8.1",
3
+ "version": "3.8.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "qmhc",