vite-plugin-dts 3.6.3 → 3.6.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
@@ -467,6 +467,10 @@ const pureImportRE = /import\s?['"][^;\n]+?['"];?\n?/g;
467
467
  function removePureImport(content) {
468
468
  return content.replace(pureImportRE, "");
469
469
  }
470
+ const asDefaultRE = /export\s*\{.*\w+\s*\bas\s+default\b.*\}\s*from\s*['"].+['"]/;
471
+ function hasExportDefault(content) {
472
+ return content.includes("export default") || asDefaultRE.test(content);
473
+ }
470
474
 
471
475
  const jsRE = /\.(m|c)?jsx?$/;
472
476
  const tsRE = /\.(m|c)?tsx?$/;
@@ -694,7 +698,7 @@ ${logPrefix} ${kolorist.yellow(
694
698
  entryRoot = ensureAbsolute(entryRoot, root);
695
699
  const diagnostics = program.getDeclarationDiagnostics();
696
700
  if (diagnostics?.length) {
697
- logger.error(ts__default.formatDiagnostics(diagnostics, host));
701
+ logger.error(ts__default.formatDiagnosticsWithColorAndContext(diagnostics, host));
698
702
  }
699
703
  if (typeof afterDiagnostic === "function") {
700
704
  await wrapPromise(afterDiagnostic(diagnostics));
@@ -888,13 +892,10 @@ ${logPrefix} ${kolorist.yellow(
888
892
  fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
889
893
  let content = `export * from '${fromPath}'
890
894
  `;
891
- if (node_fs.existsSync(index)) {
892
- const entryCodes = await promises.readFile(index, "utf-8");
893
- if (entryCodes.includes("export default")) {
894
- content += `import ${libName} from '${fromPath}'
895
+ if (node_fs.existsSync(index) && hasExportDefault(await promises.readFile(index, "utf-8"))) {
896
+ content += `import ${libName} from '${fromPath}'
895
897
  export default ${libName}
896
898
  `;
897
- }
898
899
  }
899
900
  await writeOutput(cleanPath(path), content, outDir);
900
901
  }
package/dist/index.mjs CHANGED
@@ -467,6 +467,10 @@ const pureImportRE = /import\s?['"][^;\n]+?['"];?\n?/g;
467
467
  function removePureImport(content) {
468
468
  return content.replace(pureImportRE, "");
469
469
  }
470
+ const asDefaultRE = /export\s*\{.*\w+\s*\bas\s+default\b.*\}\s*from\s*['"].+['"]/;
471
+ function hasExportDefault(content) {
472
+ return content.includes("export default") || asDefaultRE.test(content);
473
+ }
470
474
 
471
475
  const jsRE = /\.(m|c)?jsx?$/;
472
476
  const tsRE = /\.(m|c)?tsx?$/;
@@ -694,7 +698,7 @@ ${logPrefix} ${yellow(
694
698
  entryRoot = ensureAbsolute(entryRoot, root);
695
699
  const diagnostics = program.getDeclarationDiagnostics();
696
700
  if (diagnostics?.length) {
697
- logger.error(ts.formatDiagnostics(diagnostics, host));
701
+ logger.error(ts.formatDiagnosticsWithColorAndContext(diagnostics, host));
698
702
  }
699
703
  if (typeof afterDiagnostic === "function") {
700
704
  await wrapPromise(afterDiagnostic(diagnostics));
@@ -888,13 +892,10 @@ ${logPrefix} ${yellow(
888
892
  fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
889
893
  let content = `export * from '${fromPath}'
890
894
  `;
891
- if (existsSync(index)) {
892
- const entryCodes = await readFile(index, "utf-8");
893
- if (entryCodes.includes("export default")) {
894
- content += `import ${libName} from '${fromPath}'
895
+ if (existsSync(index) && hasExportDefault(await readFile(index, "utf-8"))) {
896
+ content += `import ${libName} from '${fromPath}'
895
897
  export default ${libName}
896
898
  `;
897
- }
898
899
  }
899
900
  await writeOutput(cleanPath(path), content, outDir);
900
901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "3.6.3",
3
+ "version": "3.6.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "qmhc",