Macro in JavaScript powered by Babel.
This is an experimental project, do not use in production.
yarn add @zong/js.macro
.babelrc
{
"plugins": ["macros"]
}
import { define } from '@zong/js.macro'
define`
@a:1;
@b:2;
@c:'cde';
@d:"def";
@e:true;
@f:false;
`
// Compiled
const a = 1;
const b = 2;
const c = "cde";
const d = "def";
const e = true;
const f = false;
import { define } from '@zong/js.macro'
const var1 = 2
define`
@va:${1};
@vb:${var1};
`
// Compiled
const var1 = 2;
const va = 1;
const vb = var1;