1.2.1 • Published 11 months ago

@macro-plugin/factory v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@macro-plugin/factory

Macro factories for simplify the process of creating swc AST.

Installation

# if you use npm
npm i -D @macro-plugin/factory
# if you use pnpm
pnpm i -D @macro-plugin/factory
# if you use yarn
yarn add -D @macro-plugin/factory

Usage

Given an exmaple.

import { createIdentifier } from "@macro-plugin/factory"

createIdentifier("hello")

// {
//     type: "Identifier",
//     value: "hello",
//     optional: false,
//     span: {
//         start: 0,
//         end: 0,
//         ctxt: 0
//     }
// }

Or with macros

import { $Identifier } from "@macro-plugin/factory"

$Identifier("hello")

Runtime vs Macros

The results generated by macros and runtime are the same in theory, but macros performance may be better.

For example, with runtime, if you use createIdentifier api, then the function createIdentifier will be bundled to your macro plugin.

If you use $Identifier, macro-plugin will replace your call with raw object { type: "Identifier", ... }. So it will perform better.

Built-in factory

Runtime

See runtime

Macros

See macros

1.2.0

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.2.1

11 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago