Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@macro-plugin/factory

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@macro-plugin/factory

Macro factories for creating AST.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@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

Keywords

FAQs

Package last updated on 23 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc