babel-helper-annotate-as-pure
Helper function to annotate paths and nodes with #__PURE__ comment
Last updated 8 years ago by hzoo .
MIT · Repository · Original npm
$ cnpm install babel-helper-annotate-as-pure 
SYNC missed versions from official npm registry.

babel-helper-annotate-as-pure

API

declare export default annotateAsPure(nodeOrPath: Node | NodePath);

Usage

import traverse from "babel-traverse";
import annotateAsPure from "babel-helper-annotate-as-pure";

// ...

traverse(file, {
  CallExpression(path) {
    annotateAsPure(path);
  },
});

Caveat with UglifyJS pre v3.1.0

babel-helper-annotate-as-pure will append any existing leading comments to the #__PURE__ annotation. Versions of UglifyJS prior to v3.1.0 will ignore these annotations, as they only check the last leading comment for the annotation.

For example, using the Usage snippet above:

In

const four = /* foo */ add(2, 2);

Out

const four = /* #__PURE__ */ /* foo */ add(2, 2);

Current Tags

  • 7.0.0-beta.2                                ...           latest (8 years ago)
  • 7.0.0-beta.3                                ...           next (8 years ago)

2 Versions

  • 7.0.0-beta.2                                ...           8 years ago
  • 7.0.0-beta.3                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org