Skip to content

Commit

Permalink
perf: use template argument property instead of babel-template
Browse files Browse the repository at this point in the history
  • Loading branch information
59naga committed May 4, 2016
1 parent d1922e6 commit a07c274
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
"watch": false
}
},
"dependencies": {
"babel-template": "^6.5.0"
},
"devDependencies": {
"abigail": "^1.6.1",
"babel-cli": "^6.5.1",
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import babelTemplate from 'babel-template'

module.exports = {
module.exports = ({template}) => ({
visitor: {
Program: {
exit (path) {
Expand Down Expand Up @@ -30,7 +28,7 @@ module.exports = {

if (hasExportDefault && !hasExportNamed) {
const topNodes = []
topNodes.push(babelTemplate("module.exports = exports['default']")())
topNodes.push(template("module.exports = exports['default']")())

path.pushContainer('body', topNodes)
}
Expand All @@ -39,4 +37,4 @@ module.exports = {
}
}
}
}
})
3 changes: 1 addition & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe('babel-plugin-add-module-exports', () => {

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

it('should handle duplicated plugin references (#1)', () =>
Expand Down

2 comments on commit a07c274

@jdalton
Copy link

@jdalton jdalton commented on a07c274 May 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to :shipit:?

@59naga
Copy link
Owner Author

@59naga 59naga commented on a07c274 May 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was released as v-0.2.0.

Please sign in to comment.