Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ new ReactRefreshPlugin({
### exclude

- Type: [Rspack.RuleSetCondition](https://rspack.rs/config/module-rules#condition)
- Default: `/node_modules/`
- Default: `/[\\/]node_modules[\\/]/`

Comment thread
chenjiahan marked this conversation as resolved.
Exclude files from being processed by the plugin. The value is the same as the [rule.exclude](https://rspack.rs/config/module-rules#rulesexclude) option in Rspack.

```js
new ReactRefreshPlugin({
exclude: [/node_modules/, /some-other-module/],
exclude: [/[\\/]node_modules[\\/]/, /some-other-module/],
Comment thread
chenjiahan marked this conversation as resolved.
});
```

Expand Down
4 changes: 2 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type PluginOptions = {
/**
* Exclude files from being processed by the plugin.
* The value is the same as the `rule.exclude` option in Rspack.
* @default /node_modules/
* @default /[\\/]node_modules[\\/]/
* @see https://rspack.rs/config/module-rules#rulesexclude
Comment thread
chenjiahan marked this conversation as resolved.
*/
exclude?: RuleSetCondition | null;
Expand Down Expand Up @@ -95,7 +95,7 @@ export function normalizeOptions(
options: PluginOptions,
): NormalizedPluginOptions {
d(options, 'test', /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/);
d(options, 'exclude', /node_modules/i);
d(options, 'exclude', /[\\/]node_modules[\\/]/);
d(options, 'library');
Comment on lines 97 to 99
d(options, 'forceEnable', false);
d(options, 'injectLoader', true);
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/contains-node_modules-name/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'foo';

export default 'contains-node_modules-name';
10 changes: 10 additions & 0 deletions test/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ describe('react-refresh-rspack-plugin', () => {
expect(fixture).toContain('function $RefreshReg$');
});

it('should include paths that only contain node_modules in the name', async () => {
const {
outputs: { fixture },
} = await compileWithReactRefresh(
path.join(import.meta.dirname, 'fixtures/contains-node_modules-name'),
{},
);
expect(fixture).toContain('function $RefreshReg$');
});

it('should add library to make sure work in Micro-Frontend', async () => {
const {
outputs: { reactRefresh },
Expand Down