Last active
August 29, 2015 14:22
-
-
Save jakepusateri/3be3f85f7dfa12a8e97a to your computer and use it in GitHub Desktop.
Revisions
-
jakepusateri revised this gist
Jun 4, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,6 @@ module.exports = function (babel) { /** Return function body **/ if (isYUIAdd) { return node.arguments[1].body; } }, -
jakepusateri created this gist
Jun 4, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ module.exports = function (babel) { var t = babel.types; var requires; return new babel.Transformer('plugin-example', { CallExpression: function (node, parent, scope, file) { var isYUIMethod = node.callee.object && t.isIdentifier(node.callee.object, { name: 'YUI' }); var isAddCall = node.callee.property && t.isIdentifier(node.callee.property, { name: 'add' }); var isYUIAdd = isYUIMethod && isAddCall; /** Import yui as _Y **/ file.addImport('yui', 'Y', true); /** Add requires as imports **/ var requires = node.arguments[3].properties[0]; requires.value.elements.forEach(function (element, idx) { file.addImport(element.value); }); /** Return function body **/ if (isYUIAdd) { console.log(node.arguments[1].body.body[0].expression); return node.arguments[1].body; } }, AssignmentExpression: function (node, parent, scope, file) { var isYAssignment = node.left.object.name === 'Y'; if (isYAssignment) { console.log('Assign to Y namespace detected'); } } }); }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ YUI.add('module-name', function (Y) { Y.ModuleNameSpace = { mutableY: true }; }, 'versionString', { requires: ['dependency1', 'dep2'] });