Skip to content

Commit f838012

Browse files
authored
fix: correct the type of include and exclude options (#7)
1 parent 60aa1ea commit f838012

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,34 @@ Compared to the previous approach, this method decouples the React Fast Refresh
8181
- For usage with `builtin:swc-loader`, you can refer to the example at [examples/react-refresh](https://github.com/rspack-contrib/rspack-examples/tree/main/rspack/react-refresh/rspack.config.js), When using with `swc-loader`, simply replace `builtin:swc-loader` with `swc-loader`.
8282
- For usage with `babel-loader`, you can refer to the example at [examples/react-refresh-babel-loader](https://github.com/rspack-contrib/rspack-examples/tree/main/rspack/react-refresh-babel-loader/rspack.config.js)
8383

84+
## Options
85+
86+
### include
87+
88+
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
89+
- Default: `/\.([cm]js|[jt]sx?|flow)$/i`
90+
91+
Include files to be processed by the plugin. The value is the same as the `rule.test` option in Rspack.
92+
93+
```js
94+
new ReactRefreshPlugin({
95+
include: [/\.jsx$/, /\.tsx$/],
96+
});
97+
```
98+
99+
### exclude
100+
101+
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
102+
- Default: `/node_modules/`
103+
104+
Exclude files from being processed by the plugin. The value is the same as the `rule.exclude` option in Rspack.
105+
106+
```js
107+
new ReactRefreshPlugin({
108+
exclude: [/node_modules/, /some-other-module/],
109+
});
110+
```
111+
84112
## Credits
85113

86114
Thanks to the [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) created by [@pmmmwh](https://github.com/pmmmwh), which inspires implement this plugin.

src/options.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { RuleSetCondition } from '@rspack/core';
12
import type { IntegrationType } from './utils/getSocketIntegration';
23

34
interface OverlayOptions {
@@ -11,8 +12,18 @@ interface OverlayOptions {
1112
}
1213

1314
export type PluginOptions = {
14-
include?: string | RegExp | (string | RegExp)[] | null;
15-
exclude?: string | RegExp | (string | RegExp)[] | null;
15+
/**
16+
* Include files to be processed by the plugin.
17+
* The value is the same as the `rule.test` option in Rspack.
18+
* @default /\.([cm]js|[jt]sx?|flow)$/i
19+
*/
20+
include?: RuleSetCondition | null;
21+
/**
22+
* Exclude files from being processed by the plugin.
23+
* The value is the same as the `rule.exclude` option in Rspack.
24+
* @default /node_modules/
25+
*/
26+
exclude?: RuleSetCondition | null;
1627
library?: string;
1728
forceEnable?: boolean;
1829
overlay?: boolean | OverlayOptions;

0 commit comments

Comments
 (0)