├── package.json ├── .gitignore └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-macros", 3 | "version": "1.0.0", 4 | "main": "lib/index.js", 5 | "author": "Sunil Pai ", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # osx noise 2 | .DS_Store 3 | profile 4 | 5 | # xcode noise 6 | build/* 7 | *.mode1 8 | *.mode1v3 9 | *.mode2v3 10 | *.perspective 11 | *.perspectivev3 12 | *.pbxuser 13 | *.xcworkspace 14 | xcuserdata 15 | 16 | # svn & cvs 17 | .svn 18 | CVS 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | babel-macros 2 | --- 3 | 4 | UPDATE - work on this will likely happen over at [Kent's repo](https://github.com/kentcdodds/babel-macros) 5 | 6 | (this is a readme for a project that I want to exist. previous work - [sweetjs](http://sweetjs.org/), [babel-plugin-macros](https://github.com/codemix/babel-plugin-macros)) 7 | 8 | a macro is a function that takes source code as input, and modifies it. 9 | 10 | input 11 | ```jsx 12 | // hello.macros.js 13 | export default function hello(x){ 14 | // do whatever with the node 15 | x.replaceWithSourceString(`console.log('hello' + ${x.toSource()})`)) 16 | } 17 | 18 | // app.js 19 | import hello from './hello.macros' 20 | 21 | hello('sunil') 22 | ``` 23 | 24 | output 25 | ```jsx 26 | console.log('hello' + 'sunil') 27 | ``` 28 | Works across common function call types 29 | ```jsx 30 | x(...) 31 | 32 | x`...` 33 | ``` 34 | 35 | 36 | usage 37 | --- 38 | add `'babel-macros'` to your babel config's `plugins` field. 39 | --------------------------------------------------------------------------------