Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (30 sloc) 858 Bytes
id: babel-helper-annotate-as-pure
title: @babel/helper-annotate-as-pure
sidebar_label: helper-annotate-as-pure
declare export default annotateAsPure(nodeOrPath: Node | NodePath);


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

// ...

traverse(file, {
  CallExpression(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:


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


const four = /* #__PURE__ */ /* foo */ add(2, 2);
You can’t perform that action at this time.