Skip to content

Instantly share code, notes, and snippets.

@jakepusateri
Created December 9, 2015 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakepusateri/3fc4d26cd4b716c0901c to your computer and use it in GitHub Desktop.
Save jakepusateri/3fc4d26cd4b716c0901c to your computer and use it in GitHub Desktop.
Babel 5.8.34 plugin + spec.functionName example
'use strict';
function _setDollarValue() {}
function OptionalNode() {}
OptionalNode.prototype = {
setDollarValue: function setDollarValue(value) {
_setDollarValue();
}
};
var log = require('npmlog');
var transformer = function (babel) {
var t = babel.types;
return new babel.Transformer('dep-finder', {
CallExpression: function (node, parent, scope, file) {
if (this.get("callee").matchesPattern("YUI.add")) {
var name = node.arguments[0].value;
if (name) {
/** Return function body **/
this.replaceWithMultiple(node.arguments[1].body.body);
} else {
log.error('manifest-plugin', 'bad format of YUI.add? for: ' + name);
}
}
}
});
};
module.exports = transformer;
'use strict';
function setDollarValue() {}
function OptionalNode() {}
OptionalNode.prototype = {
setDollarValue: function setDollarValue(value) {
setDollarValue();
}
};
YUI.add('zmm-loan-request-form', function (Y) {
function setDollarValue() {
}
function OptionalNode() {
}
OptionalNode.prototype = {
setDollarValue: function (value) {
setDollarValue();
}
};
},
'3.7.0',
{ requires: []});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment