1.2.5 • Published 8 days ago
react-remove-props-loader v1.2.5
React Remove Props Loader
A webpack loader for removing React props or JSX attributes in TypeScript/JavaScript code.
Install
npm install --save-dev react-remove-props-loader
# or
yarn add --dev react-remove-props-loader
Usage
In the webpack configuration, add the loader and specify props that are to be removed. The loader should be executed before any other loader, that is, it should be placed at the end of the use
array.
const { ScriptKind } = require("react-remove-props-loader");
module.exports = {
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: "react-remove-props-loader",
options: {
props: ["data-testid", "data-test-id"],
// (Optional) Set the kind of the script. Defaults to `ScriptKind.JSX`.
scriptKind: ScriptKind.TSX,
// (Optional) Set whether to remove specified props from objects. Defaults to `false`.
removeFromObjects: true,
},
},
],
},
],
},
};
Example
Source
import React, { FC } from "react";
export const ExampleComponent: FC = () => {
const propsObject = { "data-test-id": "example-prop" };
return (
<div data-testid="example-prop" {...propsObject}>
Example Component
</div>
);
};
Transformed
Code transformed with the sample settings above.
import React, { FC } from "react";
export const ExampleComponent: FC = () => {
const propsObject = { };
return (
<div {...propsObject}>
Example Component
</div>
);
};
1.2.5
8 days ago
1.2.4
5 months ago
1.2.3
8 months ago
1.2.0
10 months ago
1.2.2
8 months ago
1.2.1
9 months ago
1.1.15
12 months ago
1.1.12
1 year ago
1.1.14
1 year ago
1.1.13
1 year ago
1.1.11
1 year ago
1.1.10
1 year ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago