@zong/js.macro
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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;

/@zong/js.macro/

    Package Sidebar

    Install

    npm i @zong/js.macro

    Weekly Downloads

    3

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    11.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • zong