babel-plugin-annotate-module-pure
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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("")

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-annotate-module-pure

Weekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

7.73 kB

Total Files

5

Last publish

Collaborators

  • mozilla_firefox