Skip to content

zongzi531/js.macro

Repository files navigation

js.macro

Macro in JavaScript powered by Babel.

This is an experimental project, do not use in production.

Babel Macro

Install

yarn add @zong/js.macro

Before use

Adding the plugin to your config

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["macros"]
}

more

Use

define

Base

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;

Advanced

import { define } from '@zong/js.macro'

const var1 = 2

define`
  @va:${1};
  @vb:${var1};
`
// Compiled
const var1 = 2;
const va = 1;
const vb = var1;

About

Macro in JavaScript powered by Babel.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published