
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
@babel/plugin-transform-react-pure-annotations
Advanced tools
Mark top-level React method calls as pure for tree shaking
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.
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>;
}
}
Transforms React.createElement calls to object literals. This can improve performance by reducing the overhead of these calls at runtime. However, it does not specifically focus on tree-shaking like @babel/plugin-transform-react-pure-annotations does.
Hoists element creation to the highest scope possible. This can improve performance in React applications by reducing the need to recreate the same elements on each render. While it optimizes performance, its approach is different from adding pure annotations for tree-shaking.
Mark top-level React method calls as pure for tree shaking
See our website @babel/plugin-transform-react-pure-annotations for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-react-pure-annotations
or using yarn:
yarn add @babel/plugin-transform-react-pure-annotations --dev
v7.27.1 (2025-04-30)
babel-parser
babel-parser
, babel-types
babel-plugin-proposal-destructuring-private
, babel-plugin-proposal-do-expressions
, babel-traverse
babel-helper-wrap-function
, babel-plugin-transform-async-to-generator
babel-helper-remap-async-to-generator
, babel-plugin-transform-async-to-generator
babel-helper-fixtures
, babel-parser
babel-generator
, babel-parser
babel-parser
babel-compat-data
, babel-preset-env
babel-traverse
babel-generator
babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining
, babel-plugin-proposal-decorators
, babel-plugin-transform-arrow-functions
, babel-plugin-transform-class-properties
, babel-plugin-transform-destructuring
, babel-plugin-transform-object-rest-spread
, babel-plugin-transform-optional-chaining
, babel-plugin-transform-parameters
, babel-traverse
babel-runtime-corejs2
, babel-runtime-corejs3
, babel-runtime
regenerator-runtime
dep in @babel/runtime
(@nicolo-ribaudo)babel-compat-data
, babel-preset-env
babel-compat-data
, babel-standalone
babel-register
@babel/register
to cts (@liuxingbaoyu)babel-cli
, babel-compat-data
, babel-core
, babel-generator
, babel-helper-compilation-targets
, babel-helper-fixtures
, babel-helper-module-imports
, babel-helper-module-transforms
, babel-helper-plugin-test-runner
, babel-helper-transform-fixture-test-runner
, babel-helpers
, babel-node
, babel-parser
, babel-plugin-transform-modules-amd
, babel-plugin-transform-modules-commonjs
, babel-plugin-transform-modules-systemjs
, babel-plugin-transform-modules-umd
, babel-plugin-transform-react-display-name
, babel-plugin-transform-regenerator
, babel-plugin-transform-runtime
, babel-plugin-transform-typeof-symbol
, babel-plugin-transform-typescript
, babel-preset-env
, babel-register
, babel-standalone
, babel-types
babel-plugin-transform-regenerator
babel-helpers
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-regenerator
, babel-preset-env
, babel-runtime-corejs3
babel-helpers
, babel-plugin-transform-regenerator
babel-helpers
babel-helpers
, babel-plugin-transform-modules-commonjs
, babel-runtime-corejs3
interopRequireWildcard
size (@liuxingbaoyu)babel-helpers
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-regenerator
, babel-preset-env
, babel-runtime-corejs3
regeneratorRuntime
size (@liuxingbaoyu)FAQs
Mark top-level React method calls as pure for tree shaking
The npm package @babel/plugin-transform-react-pure-annotations receives a total of 17,290,981 weekly downloads. As such, @babel/plugin-transform-react-pure-annotations popularity was classified as popular.
We found that @babel/plugin-transform-react-pure-annotations demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.