https://github.com/threepointone/babel-macros
macros for babel. I think.
https://github.com/threepointone/babel-macros
Last synced: 2 months ago
JSON representation
macros for babel. I think.
- Host: GitHub
- URL: https://github.com/threepointone/babel-macros
- Owner: threepointone
- Created: 2016-11-02T20:01:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-07T04:43:11.000Z (almost 8 years ago)
- Last Synced: 2025-01-25T08:11:38.051Z (4 months ago)
- Size: 1.95 KB
- Stars: 12
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
babel-macros
---UPDATE - work on this will likely happen over at [Kent's repo](https://github.com/kentcdodds/babel-macros)
(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))
a macro is a function that takes source code as input, and modifies it.
input
```jsx
// hello.macros.js
export default function hello(x){
// do whatever with the node
x.replaceWithSourceString(`console.log('hello' + ${x.toSource()})`))
}// app.js
import hello from './hello.macros'hello('sunil')
```output
```jsx
console.log('hello' + 'sunil')
```
Works across common function call types
```jsx
x(...)x`...`
```usage
---
add `'babel-macros'` to your babel config's `plugins` field.