@rspack/plugin-react-refresh 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,9 +36,6 @@ Import the plugin in your code:
36
36
  ```js
37
37
  // Named import (recommended)
38
38
  import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh";
39
-
40
- // Default import
41
- import ReactRefreshRspackPlugin from "@rspack/plugin-react-refresh";
42
39
  ```
43
40
 
44
41
  - CommonJS:
@@ -103,12 +100,31 @@ Compared to the previous approach, this method decouples the React Fast Refresh
103
100
 
104
101
  ## Options
105
102
 
103
+ ### test
104
+
105
+ - Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
106
+ - Default: `undefined`
107
+
108
+ Specifies which files should be processed by the React Refresh loader. This option is passed to the `builtin:react-refresh-loader` as the `rule.test` condition.
109
+
110
+ Works identically to Rspack's [rule.test](https://rspack.dev/config/module#ruletest) option.
111
+
112
+ ```js
113
+ new ReactRefreshPlugin({
114
+ test: [/\.jsx$/, /\.tsx$/],
115
+ });
116
+ ```
117
+
106
118
  ### include
107
119
 
108
120
  - Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
109
121
  - Default: `/\.([cm]js|[jt]sx?|flow)$/i`
110
122
 
111
- Include files to be processed by the plugin. The value is the same as the [rule.test](https://rspack.dev/config/module#ruletest) option in Rspack.
123
+ Explicitly includes files to be processed by the React Refresh loader. This option is passed to the `builtin:react-refresh-loader` as the `rule.include` condition.
124
+
125
+ Use this to limit processing to specific directories or file patterns.
126
+
127
+ Works identically to Rspack's [rule.include](https://rspack.dev/config/module#ruleinclude) option.
112
128
 
113
129
  ```js
114
130
  new ReactRefreshPlugin({
@@ -6,7 +6,15 @@ const RefreshRuntime = require('react-refresh/runtime');
6
6
  function refresh(moduleId, webpackHot) {
7
7
  const currentExports = RefreshUtils.getModuleExports(moduleId);
8
8
  const fn = (exports) => {
9
- RefreshUtils.executeRuntime(exports, moduleId, webpackHot);
9
+ var errorOverlay;
10
+ if (typeof __react_refresh_error_overlay__ !== 'undefined') {
11
+ errorOverlay = __react_refresh_error_overlay__;
12
+ }
13
+ var testMode;
14
+ if (typeof __react_refresh_test__ !== 'undefined') {
15
+ testMode = __react_refresh_test__;
16
+ }
17
+ RefreshUtils.executeRuntime(exports, moduleId, webpackHot, errorOverlay, testMode);
10
18
  };
11
19
  if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
12
20
  currentExports.then(fn);
package/dist/index.js CHANGED
@@ -58,6 +58,7 @@ class ReactRefreshRspackPlugin {
58
58
  }).apply(compiler);
59
59
  if (this.options.injectLoader) {
60
60
  compiler.options.module.rules.unshift({
61
+ test: this.options.test,
61
62
  // biome-ignore lint: exists
62
63
  include: this.options.include,
63
64
  exclude: {
@@ -65,6 +66,11 @@ class ReactRefreshRspackPlugin {
65
66
  or: [this.options.exclude, [...paths_1.runtimePaths]].filter(Boolean),
66
67
  },
67
68
  resourceQuery: this.options.resourceQuery,
69
+ dependency: {
70
+ // `new URL("static/sdk.js", import.meta.url)` the sdk.js is an asset module
71
+ // we shoudn't inject react refresh for asset module
72
+ not: ['url'],
73
+ },
68
74
  use: ReactRefreshRspackPlugin.loader,
69
75
  });
70
76
  }
package/dist/options.d.ts CHANGED
@@ -11,11 +11,20 @@ interface OverlayOptions {
11
11
  }
12
12
  export type PluginOptions = {
13
13
  /**
14
- * Include files to be processed by the plugin.
15
- * The value is the same as the `rule.test` option in Rspack.
16
- * @default /\.([cm]js|[jt]sx?|flow)$/i
14
+ * Specifies which files should be processed by the React Refresh loader.
15
+ * This option is passed to the `builtin:react-refresh-loader` as the `rule.test` condition.
16
+ * Works identically to Rspack's `rule.test` option.
17
17
  * @see https://rspack.dev/config/module#ruletest
18
18
  */
19
+ test?: RuleSetCondition;
20
+ /**
21
+ * Explicitly includes files to be processed by the React Refresh loader.
22
+ * This option is passed to the `builtin:react-refresh-loader` as the `rule.include` condition.
23
+ * Use this to limit processing to specific directories or file patterns.
24
+ * Works identically to Rspack's `rule.include` option.
25
+ * @default /\.([cm]js|[jt]sx?|flow)$/i
26
+ * @see https://rspack.dev/config/module#ruleinclude
27
+ */
19
28
  include?: RuleSetCondition | null;
20
29
  /**
21
30
  * Exclude files from being processed by the plugin.
package/exports/index.cjs CHANGED
@@ -1,4 +1,7 @@
1
1
  // CommonJS wrapper
2
2
  const { ReactRefreshRspackPlugin } = require('../dist/index.js');
3
3
 
4
+ // default export will be deprecated in next major version
4
5
  module.exports = ReactRefreshRspackPlugin;
6
+
7
+ module.exports.ReactRefreshRspackPlugin = ReactRefreshRspackPlugin;
package/exports/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // ES modules wrapper
2
2
  import { ReactRefreshRspackPlugin } from '../dist/index.js';
3
-
3
+ // default export will be deprecated in next major version
4
4
  export default ReactRefreshRspackPlugin;
5
5
  export { ReactRefreshRspackPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/plugin-react-refresh",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "repository": "https://github.com/rspack-contrib/rspack-plugin-react-refresh",
5
5
  "license": "MIT",
6
6
  "description": "React refresh plugin for Rspack",
@@ -32,24 +32,23 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@biomejs/biome": "^1.9.4",
35
- "@continuous-auth/client": "2.3.2",
36
- "@rslib/core": "^0.6.8",
37
- "@rspack/core": "1.3.8",
35
+ "@rslib/core": "^0.11.0",
36
+ "@rspack/core": "1.4.11",
38
37
  "@types/jest": "29.5.14",
39
- "@types/node": "^22.15.3",
40
- "cross-env": "^7.0.3",
41
- "execa": "9.5.2",
38
+ "@types/node": "^22.17.0",
39
+ "cross-env": "^10.0.0",
40
+ "execa": "9.6.0",
42
41
  "fs-extra": "11.3.0",
43
42
  "jest": "29.7.0",
44
43
  "jest-cli": "29.7.0",
45
44
  "jest-environment-node": "29.7.0",
46
45
  "nano-staged": "^0.8.0",
47
46
  "react-refresh": "^0.17.0",
48
- "semver": "7.7.1",
49
- "simple-git-hooks": "^2.13.0",
50
- "ts-jest": "29.3.2",
47
+ "semver": "7.7.2",
48
+ "simple-git-hooks": "^2.13.1",
49
+ "ts-jest": "29.4.0",
51
50
  "ts-node": "^10.9.2",
52
- "typescript": "5.8.3"
51
+ "typescript": "5.9.2"
53
52
  },
54
53
  "dependencies": {
55
54
  "error-stack-parser": "^2.1.4",
@@ -66,8 +65,7 @@
66
65
  },
67
66
  "publishConfig": {
68
67
  "access": "public",
69
- "registry": "https://registry.npmjs.org/",
70
- "provenance": true
68
+ "registry": "https://registry.npmjs.org/"
71
69
  },
72
70
  "scripts": {
73
71
  "build": "tsc -b ./tsconfig.build.json",