Skip to content

Commit

Permalink
Merge pull request #33 from 59naga/patch-1
Browse files Browse the repository at this point in the history
fix #31 plugin should export using module.exports
  • Loading branch information
59naga committed Apr 26, 2016
2 parents 50253c8 + ae8b254 commit 8c39825
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"cover:test": "nyc --reporter=lcov --reporter=text npm test",
"cover:report": "npm-if TRAVIS \"codeclimate-test-reporter < coverage/lcov.info\"",
"lint": "eslint src test",
"version": "node changelog.js > CHANGELOG.md && git add CHANGELOG.md",
"postversion": "git push --follow-tags",
"postversion": "node changelog.js > CHANGELOG.md && git add CHANGELOG.md && echo ':wq' | git commit --amend && git push --follow-tags",
"build": "abby compile --log --env"
},
"nyc": {
Expand All @@ -40,8 +39,7 @@
}
},
"dependencies": {
"babel-template": "^6.5.0",
"lodash.get": "^4.2.1"
"babel-template": "^6.5.0"
},
"devDependencies": {
"abigail": "^1.6.1",
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import babelTemplate from 'babel-template'
import _get from 'lodash.get'

export default {
module.exports = {
visitor: {
Program: {
exit (path) {
Expand All @@ -18,7 +17,7 @@ export default {
}
if (path.isExportNamedDeclaration()) {
// HACK detect export-from statements for default
const specifiers = _get(path.get('declaration'), 'container.specifiers')
const specifiers = path.get('declaration').container.specifiers
const isDefaultExportDeclaration = specifiers.length === 1 && specifiers[0].exported.name === 'default'
if (isDefaultExportDeclaration) {
hasExportDefault = true
Expand Down
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ describe('babel-plugin-add-module-exports', () => {
assert(module.default === 'default-entry')
}))

it('plugin should export to module.exports(#31)', () => {
const plugin = require('../lib')
assert(typeof plugin === 'object')
assert(typeof plugin.visitor === 'object')
})

it('should handle duplicated plugin references (#1)', () =>
heplers.testPlugin(testCases[0].code, {
presets: ['es2015'],
Expand Down

0 comments on commit 8c39825

Please sign in to comment.