1.0.2 • Published 1 month ago

babel-plugin-annotate-module-pure v1.0.2

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

babel-plugin-annotate-module-pure

Mark module method call as pure for tree shaking

Usage

{
  "plugins": [
    ["babel-plugin-annotate-module-pure", { 
      "pureCalls": {
        "react": [
          "cloneElement",
          "createContext",
          "createElement",
          "createFactory",
          "createRef",
          "forwardRef",
          "isValidElement",
          "lazy",
          "memo",
        ],
        "react-dom": ["createPortal"],
        "webextension-polyfill": [
          ["runtime", "getManifest"],
          ["runtime", "getURL"],
          ["default", "runtime", "getManifest"],
          ["default", "runtime", "getURL"],
        ],
      }
    }]
  ]
}
import { createContext } from "react"
import Browser, { runtime } from "webextension-polyfill"

const Ctx = createContext(null)
const imageUrl = Browser.runtime.getURL("image.png")
const videoUrl = runtime.getURL("")

// becomes 👇

const Ctx = /* #__PURE__ */ createContext(null)
const imageUrl = /* #__PURE__ */ Browser.runtime.getURL("image.png")
const videoUrl = /* #__PURE__ */ runtime.getURL("")
1.0.2

1 month ago

1.0.1

1 month ago

1.0.0

2 months ago