Skip to content

Commit

Permalink
fix: prevent multiple exports of multiple signatures (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassilah committed Feb 7, 2022
1 parent 51bdf4d commit d492116
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/analyze.ts
Expand Up @@ -109,7 +109,11 @@ export function findExports (code: string): ESMExport[] {
const starExports = matchAll(EXPORT_STAR_RE, code, { type: 'star' })

// Merge and normalize exports
const exports = [].concat(declaredExports, namedExports, defaultExport, starExports)
const exports = [].concat(declaredExports, namedExports, defaultExport, starExports).filter((exp, index, exports) => {
// Prevent multiple exports of same function, only keep latest iteration of signatures
return !exports[index + 1] || exp.name !== exports[index + 1].name
})

for (const exp of exports) {
if (!exp.name && exp.names && exp.names.length === 1) {
exp.name = exp.names[0]
Expand Down

0 comments on commit d492116

Please sign in to comment.