Babel Plugin for Removing React Properties

0.3.1 · maintenance · verified Sun Apr 19

This Babel plugin, currently at stable version 0.3.1, is designed to remove specified React component properties during the JavaScript transpilation process. Its primary use case is for optimizing production builds by stripping out attributes like `data-test` or `data-qa`, which are often used for testing and debugging but are unnecessary in deployed code. This minification helps reduce the final bundle size and prevents exposing internal testing hooks to end-users. The package has seen a slow release cadence, with recent updates focused on maintenance and minor feature enhancements. It differentiates itself through its focused application on React properties, providing a cleaner, more efficient production DOM compared to manually removing these attributes or leaving them in. It's configured via Babel's standard `.babelrc` or `babel.config.js` files, allowing for granular control over which properties (including those matching regular expressions) are removed, typically activated only in production environments.

Common errors

Warnings

Install

Imports

Quickstart

This `.babelrc` configuration demonstrates how to remove specific React properties (like `data-test`, `data-qa`, and any property starting with `_qa` followed by digits) exclusively in production builds.

{
  "env": {
    "production": {
      "plugins": [
        ["react-remove-properties", {"properties": ["data-test", "data-qa", /^_qa\d+$/]}]
      ]
    }
  }
}

view raw JSON →