Skip to content

Commit 8c39825

Browse files
committed
Merge pull request #33 from 59naga/patch-1
fix #31 plugin should export using module.exports
2 parents 50253c8 + ae8b254 commit 8c39825

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"cover:test": "nyc --reporter=lcov --reporter=text npm test",
2424
"cover:report": "npm-if TRAVIS \"codeclimate-test-reporter < coverage/lcov.info\"",
2525
"lint": "eslint src test",
26-
"version": "node changelog.js > CHANGELOG.md && git add CHANGELOG.md",
27-
"postversion": "git push --follow-tags",
26+
"postversion": "node changelog.js > CHANGELOG.md && git add CHANGELOG.md && echo ':wq' | git commit --amend && git push --follow-tags",
2827
"build": "abby compile --log --env"
2928
},
3029
"nyc": {
@@ -40,8 +39,7 @@
4039
}
4140
},
4241
"dependencies": {
43-
"babel-template": "^6.5.0",
44-
"lodash.get": "^4.2.1"
42+
"babel-template": "^6.5.0"
4543
},
4644
"devDependencies": {
4745
"abigail": "^1.6.1",

src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import babelTemplate from 'babel-template'
2-
import _get from 'lodash.get'
32

4-
export default {
3+
module.exports = {
54
visitor: {
65
Program: {
76
exit (path) {
@@ -18,7 +17,7 @@ export default {
1817
}
1918
if (path.isExportNamedDeclaration()) {
2019
// HACK detect export-from statements for default
21-
const specifiers = _get(path.get('declaration'), 'container.specifiers')
20+
const specifiers = path.get('declaration').container.specifiers
2221
const isDefaultExportDeclaration = specifiers.length === 1 && specifiers[0].exported.name === 'default'
2322
if (isDefaultExportDeclaration) {
2423
hasExportDefault = true

test/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ describe('babel-plugin-add-module-exports', () => {
1111
assert(module.default === 'default-entry')
1212
}))
1313

14+
it('plugin should export to module.exports(#31)', () => {
15+
const plugin = require('../lib')
16+
assert(typeof plugin === 'object')
17+
assert(typeof plugin.visitor === 'object')
18+
})
19+
1420
it('should handle duplicated plugin references (#1)', () =>
1521
heplers.testPlugin(testCases[0].code, {
1622
presets: ['es2015'],

0 commit comments

Comments
 (0)