babel-macros
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -12,5 +12,3 @@ 'use strict'; | ||
visitor: { | ||
ImportDeclaration(path, _ref) { | ||
var filename = _ref.file.opts.filename; | ||
ImportDeclaration(path, state) { | ||
var isMacros = looksLike(path, { | ||
@@ -30,8 +28,6 @@ node: { | ||
var source = path.node.source.value; | ||
applyMacros({ path, name, source, filename }); | ||
applyMacros({ path, name, source, state }); | ||
path.remove(); | ||
}, | ||
CallExpression(path, _ref2) { | ||
var filename = _ref2.file.opts.filename; | ||
CallExpression(path, state) { | ||
var isMacros = looksLike(path, { | ||
@@ -56,3 +52,3 @@ node: { | ||
var source = path.node.arguments[0].value; | ||
applyMacros({ path, name, source, filename }); | ||
applyMacros({ path, name, source, state }); | ||
path.parentPath.remove(); | ||
@@ -64,7 +60,8 @@ } | ||
function applyMacros(_ref3) { | ||
var path = _ref3.path, | ||
name = _ref3.name, | ||
source = _ref3.source, | ||
filename = _ref3.filename; | ||
function applyMacros(_ref) { | ||
var path = _ref.path, | ||
name = _ref.name, | ||
source = _ref.source, | ||
state = _ref.state; | ||
var filename = state.file.opts.filename; | ||
@@ -81,5 +78,5 @@ var referencePaths = path.scope.getBinding(name).referencePaths; | ||
if (ref.parentPath.type === 'TaggedTemplateExpression') { | ||
macros.asTag(ref.parentPath.get('quasi')); | ||
macros.asTag(ref.parentPath.get('quasi'), state); | ||
} else if (ref.parentPath.type === 'CallExpression') { | ||
macros.asFunction(ref.parentPath.get('arguments')); | ||
macros.asFunction(ref.parentPath.get('arguments'), state); | ||
} else if (ref.parentPath.type === 'JSXOpeningElement') { | ||
@@ -89,3 +86,3 @@ macros.asJSX({ | ||
children: ref.parentPath.parentPath.get('children') | ||
}); | ||
}, state); | ||
} else { | ||
@@ -92,0 +89,0 @@ // TODO: throw a helpful error message |
{ | ||
"name": "babel-macros", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Enables zero-config, importable babel plugins", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
<div style="text-align:center"> | ||
# babel-macros | ||
Enables zero-config, importable babel plugins | ||
# babel-macros 🎣 | ||
**Enables zero-config, importable babel plugins** | ||
</div> | ||
@@ -37,3 +39,4 @@ | ||
// TODO | ||
This is a work in progress and the form of the solution will likely change a lot | ||
before `1.0.0` is released. Collaboration is welcome! | ||
@@ -40,0 +43,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11298
113
95