This Babel plugin automatically strips specified `data-*` attributes (by default, `data-test-id`) from JSX elements during the build process. Its primary motivation is to clean up the production DOM by removing attributes primarily used for end-to-end testing, potentially reducing bundle size and preventing these attributes from appearing in user-facing code. Developed around a pattern suggested at React Alicante in 2017, the package is currently at version 1.1.0 and was last updated over 8 years ago. Given its lack of recent activity and minimal version changes, it is considered stable but largely unmaintained. Key differentiators include its simplicity and direct integration into the Babel pipeline, providing a compile-time solution for attribute removal without runtime overhead.
npm install babel-plugin-remove-test-idsVerified import paths — ran on the pinned version, not inferred.
This configuration shows how to integrate `babel-plugin-remove-test-ids` into your Babel setup to automatically strip test-related attributes from JSX during compilation.
Consider migrating to actively maintained alternatives like `babel-plugin-jsx-remove-data-test-id` or `@svgr/babel-plugin-remove-jsx-attribute` for better Babel 7+ compatibility and ongoing support.
Ensure `"remove-test-ids"` is placed before any other plugins that could transform or remove JSX attributes or elements in your Babel configuration. For environment-specific removal, configure the plugin only for production builds using Babel's `env` option.
Verify that the plugin is running at a stage where the JSX attributes are still in their original form. If using complex transformations, you might need to test the output or consider a custom Babel plugin tailored to your specific AST structure.
First, ensure the plugin is installed: `npm install babel-plugin-remove-test-ids --save-dev`. If using `babel.config.js`, specify the full path using `require.resolve('babel-plugin-remove-test-ids')`.Ensure the plugin options are passed as a JSON object within an array, following the pattern `["plugin-name", { "optionKey": "value" }]`. Double-check the plugin's documentation for its expected options structure.Verify that your Babel configuration correctly applies the `remove-test-ids` plugin specifically to your production build (e.g., using Babel's `env.production` configuration). Ensure there are no conflicting plugins or transforms. Confirm that the attributes you want to remove are correctly listed in the plugin's `attributes` option if you are using custom names.
No dependency data recorded yet.