Skip to content

Commit

Permalink
fix: ensure inserted index file be a module
Browse files Browse the repository at this point in the history
fix #365
  • Loading branch information
qmhc committed Aug 9, 2024
1 parent b7df107 commit f93e98c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,15 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin {
fromPath = fromPath.replace(dtsRE, '')
fromPath = fullRelativeRE.test(fromPath) ? fromPath : `./${fromPath}`

let content = ''
let content = 'export {}\n'

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

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

Expand Down

0 comments on commit f93e98c

Please sign in to comment.