Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Commit 81f3758

Browse files
committed
docs: add info about warning log supression
1 parent 25944a0 commit 81f3758

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
**webpack-react-component-name** is a Webpack plugin that makes your custom
44
React components visible within React Dev Tools and other tools that rely on the displayName parameter.
55

6-
*Note: This fork contains the version of this plugin that is compatible with
7-
Webpack 5. For support for Webpack 4, see version 4.x of the [Original Repo](https://github.com/runreflect/webpack-react-component-name/releases/tag/4.0.5).*
6+
_Note: This fork contains the version of this plugin that is compatible with
7+
Webpack 5. For support for Webpack 4, see version 4.x of the [Original Repo](https://github.com/runreflect/webpack-react-component-name/releases/tag/4.0.5)._
88

9-
Normally React component names are minified during compilation. This plugin
9+
Normally React component names are minified during compilation. This plugin
1010
makes these component names available in production bundles by hooking into
1111
Webpack's compilation process, traversing the AST looking for React component
12-
definitions, and updating the emitted source code to populate the
12+
definitions, and updating the emitted source code to populate the
1313
[displayName](https://reactjs.org/docs/react-component.html#displayname)
14-
property. This is the property that, when populated, is used by the React Dev
14+
property. This is the property that, when populated, is used by the React Dev
1515
Tools extension to determine the name of a component.
1616

1717
Since we emit a `displayName` property value for each React component definition
18-
(critically, **not** every React component *instance*), using this plugin will
18+
(critically, **not** every React component _instance_), using this plugin will
1919
result in a small size increase to your production bundles.
2020

2121
## Installation
@@ -51,33 +51,55 @@ Default: `false`
5151

5252
If set true, the plugin will name the components exported from node_modules.
5353

54+
### include
5455

55-
### include
5656
Type: `(string | RegExp | (path: string) => boolean)[]` Default: `[]`
5757

5858
If the path matches any of the elements in this array, it will be included if it isn't explicitly excluded.
5959

60-
If the item is a `string`, it will use standard glob syntax. If the item is a Regular Expression, the path will be tested against it. If the item is a function, the path will be passed into it for testing.
60+
If the item is a `string`, it will use standard glob syntax. If the item is a Regular Expression, the path will be tested against it. If the item is a function, the path will be passed into it for testing.
61+
62+
### exclude
6163

62-
### exclude
6364
Type: `(string | RegExp | (path: string) => boolean)[]` Default: `[]`
6465

6566
If the path matches any of the elements in this array, it will be excluded.
6667

67-
If the item is a `string`, it will use standard glob syntax. If the item is a Regular Expression, the path will be tested against it. If the item is a function, the path will be passed into it for testing.
68+
If the item is a `string`, it will use standard glob syntax. If the item is a Regular Expression, the path will be tested against it. If the item is a function, the path will be passed into it for testing.
69+
70+
A truthy result will be excluded.
6871

69-
A truthy result will be excluded.
7072
## Troubleshooting
7173

72-
As you probably know, there is more than one way to define a React component. This
74+
As you probably know, there is more than one way to define a React component. This
7375
plugin attempts to detect every possible way of defining a component, but there may
74-
be some we've missed. See the `/examples` directory and the unit tests for examples
76+
be some we've missed. See the `/examples` directory and the unit tests for examples
7577
of the different permutations of React component definitions that we currently support.
7678

7779
If we are not detecting one of your components, please either file an Issue containing
7880
example source for a component which is not detected, or feel free to open a PR with
7981
the fix.
8082

83+
## Note for Next.js users
84+
85+
In Next.js the plugin may cause warnings like `[webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item` to be generated. These warnings are safe to ignore without any further action. But if you'd like to supress these warnings, as an interim solution, the following snippet can be added to your webpack config.
86+
87+
```js
88+
const webpackComponentNamesAppenderCacheWarning =
89+
/Skipped not serializable cache item.*ModuleAppenderDependency/i;
90+
91+
config.infrastructureLogging = {
92+
stream: {
93+
write: (message) => {
94+
if (webpackComponentNamesAppenderCacheWarning.test(message)) {
95+
return;
96+
}
97+
process.stderr.write(message);
98+
},
99+
},
100+
};
101+
```
102+
81103
## License
82104

83105
This project is licensed under the terms of the MIT license. See `LICENSE.md` for more info.

0 commit comments

Comments
 (0)