vite-plugin-dts 4.0.0 → 4.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.cjs CHANGED
@@ -661,16 +661,20 @@ function transformCode(options) {
661
661
  diffLineCount: importMap.size && importCount < importMap.size ? importMap.size - importCount : null
662
662
  };
663
663
  }
664
- function hasNamedExport(content) {
664
+ function hasNormalExport(content) {
665
665
  const ast = ts__default.createSourceFile("a.ts", content, ts__default.ScriptTarget.Latest);
666
666
  let has = false;
667
667
  walkSourceFile(ast, (node) => {
668
- if (ts__default.isExportDeclaration(node) && node.exportClause && ts__default.isNamedExports(node.exportClause)) {
669
- for (const element of node.exportClause.elements) {
670
- if (element.name.escapedText !== "default") {
671
- has = true;
672
- break;
668
+ if (ts__default.isExportDeclaration(node)) {
669
+ if (node.exportClause && ts__default.isNamedExports(node.exportClause)) {
670
+ for (const element of node.exportClause.elements) {
671
+ if (element.name.escapedText !== "default") {
672
+ has = true;
673
+ break;
674
+ }
673
675
  }
676
+ } else {
677
+ has = true;
674
678
  }
675
679
  } else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
676
680
  for (let i = 0, len = node.modifiers.length; i < len; ++i) {
@@ -1181,16 +1185,16 @@ ${logPrefix} ${kolorist.yellow(
1181
1185
  let fromPath = normalizePath(node_path.relative(node_path.dirname(entryDtsPath), sourceEntry));
1182
1186
  fromPath = fromPath.replace(dtsRE, "");
1183
1187
  fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
1184
- let content = "";
1188
+ let content = "export {}\n";
1185
1189
  if (emittedFiles.has(sourceEntry)) {
1186
- if (hasNamedExport(emittedFiles.get(sourceEntry))) {
1187
- content += `export * from '${fromPath}'
1188
- `;
1190
+ if (hasNormalExport(emittedFiles.get(sourceEntry))) {
1191
+ content = `export * from '${fromPath}'
1192
+ ${content}`;
1189
1193
  }
1190
1194
  if (hasExportDefault(emittedFiles.get(sourceEntry))) {
1191
1195
  content += `import ${libName} from '${fromPath}'
1192
1196
  export default ${libName}
1193
- `;
1197
+ ${content}`;
1194
1198
  }
1195
1199
  }
1196
1200
  await writeOutput(cleanPath(entryDtsPath), content, outDir);
package/dist/index.mjs CHANGED
@@ -657,16 +657,20 @@ function transformCode(options) {
657
657
  diffLineCount: importMap.size && importCount < importMap.size ? importMap.size - importCount : null
658
658
  };
659
659
  }
660
- function hasNamedExport(content) {
660
+ function hasNormalExport(content) {
661
661
  const ast = ts.createSourceFile("a.ts", content, ts.ScriptTarget.Latest);
662
662
  let has = false;
663
663
  walkSourceFile(ast, (node) => {
664
- if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
665
- for (const element of node.exportClause.elements) {
666
- if (element.name.escapedText !== "default") {
667
- has = true;
668
- break;
664
+ if (ts.isExportDeclaration(node)) {
665
+ if (node.exportClause && ts.isNamedExports(node.exportClause)) {
666
+ for (const element of node.exportClause.elements) {
667
+ if (element.name.escapedText !== "default") {
668
+ has = true;
669
+ break;
670
+ }
669
671
  }
672
+ } else {
673
+ has = true;
670
674
  }
671
675
  } else if ("modifiers" in node && Array.isArray(node.modifiers) && node.modifiers.length > 1) {
672
676
  for (let i = 0, len = node.modifiers.length; i < len; ++i) {
@@ -1177,16 +1181,16 @@ ${logPrefix} ${yellow(
1177
1181
  let fromPath = normalizePath(relative(dirname(entryDtsPath), sourceEntry));
1178
1182
  fromPath = fromPath.replace(dtsRE, "");
1179
1183
  fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`;
1180
- let content = "";
1184
+ let content = "export {}\n";
1181
1185
  if (emittedFiles.has(sourceEntry)) {
1182
- if (hasNamedExport(emittedFiles.get(sourceEntry))) {
1183
- content += `export * from '${fromPath}'
1184
- `;
1186
+ if (hasNormalExport(emittedFiles.get(sourceEntry))) {
1187
+ content = `export * from '${fromPath}'
1188
+ ${content}`;
1185
1189
  }
1186
1190
  if (hasExportDefault(emittedFiles.get(sourceEntry))) {
1187
1191
  content += `import ${libName} from '${fromPath}'
1188
1192
  export default ${libName}
1189
- `;
1193
+ ${content}`;
1190
1194
  }
1191
1195
  }
1192
1196
  await writeOutput(cleanPath(entryDtsPath), content, outDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-dts",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "type": "module",
5
5
  "packageManager": "pnpm@8.3.0",
6
6
  "license": "MIT",