Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-react-pure-annotations

Package Overview
Dependencies
55
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

@babel/plugin-transform-react-pure-annotations

Mark top-level React method calls as pure for tree shaking

    7.23.3latest
    GitHub
    npm

Version published
Maintainers
4
Weekly downloads
12,691,901
increased by4.55%

Weekly downloads

Package description

What is @babel/plugin-transform-react-pure-annotations?

The @babel/plugin-transform-react-pure-annotations package is a Babel plugin designed to enhance optimization for React components by automatically annotating React components with `/*#__PURE__*/` comments. These comments signal to JavaScript bundlers and minifiers, such as Terser, that the component functions can be safely tree-shaken if they are not used. This can lead to smaller bundle sizes in production builds.

What are @babel/plugin-transform-react-pure-annotations's main functionalities?

Automatic Pure Annotation for Functional Components

Automatically adds pure annotations to functional React components, indicating that they can be safely removed if unused.

Before:
const MyComponent = () => <div>Hello World</div>;

After:
const MyComponent = /*#__PURE__*/() => <div>Hello World</div>;

Automatic Pure Annotation for Class Components

Automatically adds pure annotations to the return value of render methods in class components, aiding in their potential tree-shaking.

Before:
class MyComponent extends React.Component {
  render() {
    return <div>Hello World</div>;
  }
}

After:
class MyComponent extends React.Component {
  render() {
    return /*#__PURE__*/<div>Hello World</div>;
  }
}

Other packages similar to @babel/plugin-transform-react-pure-annotations

Changelog

Source

v7.23.3 (2023-11-09)

:bug: Bug Fix
  • babel-plugin-transform-typescript
    • #16071 Strip type-only TS namespaces (@colinaaa)
  • babel-generator
  • babel-compat-data, babel-plugin-bugfix-v8-static-class-fields-redefine-readonly, babel-preset-env
  • babel-plugin-transform-object-super
  • babel-helper-module-transforms, babel-plugin-transform-modules-amd, babel-plugin-transform-modules-commonjs, babel-plugin-transform-modules-umd
:memo: Documentation
  • #16044 docs: Update links in @babel/eslint-parser README (@aryehb)
:house: Internal
  • babel-core, babel-preset-env
:running_woman: Performance
:microscope: Output optimization
  • babel-plugin-transform-computed-properties

Readme

Source

@babel/plugin-transform-react-pure-annotations

Mark top-level React method calls as pure for tree shaking

See our website @babel/plugin-transform-react-pure-annotations for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-transform-react-pure-annotations

or using yarn:

yarn add @babel/plugin-transform-react-pure-annotations --dev

Keywords

FAQs

Last updated on 09 Nov 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc