Skip to content

Commit

Permalink
fix: module.exports not add more than once
Browse files Browse the repository at this point in the history
`module.exports` was added as many times as the plugin was called
  • Loading branch information
59naga committed Jul 2, 2018
1 parent 3f28087 commit 4d29040
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ExportFinder {
this.path = path
this.hasExportDefault = false
this.hasExportNamed = false
this.hasModuleExports = false
}
getRootPath () {
return this.path.parentPath.parentPath
Expand All @@ -56,7 +57,7 @@ class ExportFinder {
}
}
})
return this.hasExportDefault && !this.hasExportNamed
return this.hasExportDefault && !this.hasExportNamed && !this.hasModuleExports
}
findExport (path, property = 'expression') {
// Not `exports.anything`, skip
Expand All @@ -73,6 +74,9 @@ class ExportFinder {
this.hasExportNamed = true
}
}
if (`${objectName}.${propertyName}` === 'module.exports') {
this.hasModuleExports = true
}
return null
}
}

0 comments on commit 4d29040

Please sign in to comment.