Code Monkey home page Code Monkey logo

babel-plugin-pure-calls-annotation's Introduction

babel-plugin-pure-calls-annotation

test codecov npm dep

Automated annotate /*#__PURE__*/ to call expression which in variable declarator, assignment expression, arguments of call expression and other expressions as values

Purpose

help to annotate /*#__PURE__*/ to drop dead code in Webpack for uglyfiy and tree shaking

Will transform

export const call = (s) => {
    return "call" + s
}

export const stringA = call("a")
export const stringB = (() => call("b"))()

to

export const call = (s) => {
    return "call" + s
}

export const stringA = /*#__PURE__*/call("a")
export const stringB = /*#__PURE__*/(() => call("b"))()

Notice:

code like below will not be pure call

const a = setInterval(() => {
    console.log(a)
}, 1000)

babel-plugin-pure-calls-annotation's People

Contributors

ckknight avatar morlay avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

andarist ckknight

babel-plugin-pure-calls-annotation's Issues

Doesn't annotate IIFE

I found that either documentation isn't correct or it's a bug, because immediately invoked functions (IIFE) aren't being processed.

script.js:

export const call = (s) => {
  return "call" + s
}

export const stringA = call("a")
export const stringB = (() => call("b"))()

Run in console (babel v7):

$ npx babel --plugins pure-calls-annotation script.js

export const call = s => {
  return "call" + s;
};
export const stringA = /*#__PURE__*/call("a");
export const stringB = (() => call("b"))();

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.