Skip to content

Commit f93e98c

Browse files
committed
fix: ensure inserted index file be a module
fix #365
1 parent b7df107 commit f93e98c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,15 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin {
671671
fromPath = fromPath.replace(dtsRE, '')
672672
fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`
673673

674-
let content = ''
674+
let content = 'export {}\n'
675675

676676
if (emittedFiles.has(sourceEntry)) {
677677
if (hasNormalExport(emittedFiles.get(sourceEntry)!)) {
678-
content += `export * from '${fromPath}'\n`
678+
content = `export * from '${fromPath}'\n${content}`
679679
}
680680

681681
if (hasExportDefault(emittedFiles.get(sourceEntry)!)) {
682-
content += `import ${libName} from '${fromPath}'\nexport default ${libName}\n`
682+
content += `import ${libName} from '${fromPath}'\nexport default ${libName}\n${content}`
683683
}
684684
}
685685

0 commit comments

Comments
 (0)