@rsbuild/plugin-react 0.6.6 → 0.6.7

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Rspack, RsbuildPlugin } from '@rsbuild/core';
2
+ import { PluginOptions } from '@rspack/plugin-react-refresh';
2
3
 
3
4
  type SplitReactChunkOptions = {
4
5
  /**
@@ -24,7 +25,16 @@ type PluginReactOptions = {
24
25
  * Configuration for chunk splitting of React-related dependencies.
25
26
  */
26
27
  splitChunks?: SplitReactChunkOptions;
28
+ /**
29
+ * When set to `true`, enables the React Profiler for performance analysis in production builds.
30
+ * @default false
31
+ */
27
32
  enableProfiler?: boolean;
33
+ /**
34
+ * Options passed to `@rspack/plugin-react-refresh`
35
+ * @see https://rspack.dev/guide/tech/react#rspackplugin-react-refresh
36
+ */
37
+ reactRefreshOptions?: PluginOptions;
28
38
  };
29
39
  declare const PLUGIN_REACT_NAME = "rsbuild:react";
30
40
  declare const pluginReact: ({ enableProfiler, ...options }?: PluginReactOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -68,7 +68,12 @@ var applyBasicReactSupport = (api, options) => {
68
68
  }
69
69
  chain.resolve.alias.set("react-refresh", import_node_path.default.dirname(REACT_REFRESH_PATH));
70
70
  const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
71
- chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [{ include: [import_shared.SCRIPT_REGEX] }]);
71
+ chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
72
+ {
73
+ include: [import_shared.SCRIPT_REGEX],
74
+ ...options.reactRefreshOptions
75
+ }
76
+ ]);
72
77
  });
73
78
  };
74
79
  var applyReactProfiler = (api) => {
@@ -148,10 +153,10 @@ var pluginReact = ({
148
153
  } = {}) => ({
149
154
  name: PLUGIN_REACT_NAME,
150
155
  setup(api) {
151
- const isEnvProductionProfile = enableProfiler && (0, import_shared3.getNodeEnv)() === "production";
152
156
  if (api.context.bundlerType === "rspack") {
153
157
  applyBasicReactSupport(api, options);
154
- if (isEnvProductionProfile) {
158
+ const isProdProfile = enableProfiler && (0, import_shared3.getNodeEnv)() === "production";
159
+ if (isProdProfile) {
155
160
  applyReactProfiler(api);
156
161
  }
157
162
  }
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  throw Error('Dynamic require of "' + x + '" is not supported');
10
10
  });
11
11
 
12
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.0_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.1_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
13
  import { fileURLToPath } from "url";
14
14
  import path from "path";
15
15
 
@@ -52,7 +52,12 @@ var applyBasicReactSupport = (api, options) => {
52
52
  }
53
53
  chain.resolve.alias.set("react-refresh", path2.dirname(REACT_REFRESH_PATH));
54
54
  const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
55
- chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [{ include: [SCRIPT_REGEX] }]);
55
+ chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
56
+ {
57
+ include: [SCRIPT_REGEX],
58
+ ...options.reactRefreshOptions
59
+ }
60
+ ]);
56
61
  });
57
62
  };
58
63
  var applyReactProfiler = (api) => {
@@ -136,10 +141,10 @@ var pluginReact = ({
136
141
  } = {}) => ({
137
142
  name: PLUGIN_REACT_NAME,
138
143
  setup(api) {
139
- const isEnvProductionProfile = enableProfiler && getNodeEnv() === "production";
140
144
  if (api.context.bundlerType === "rspack") {
141
145
  applyBasicReactSupport(api, options);
142
- if (isEnvProductionProfile) {
146
+ const isProdProfile = enableProfiler && getNodeEnv() === "production";
147
+ if (isProdProfile) {
143
148
  applyReactProfiler(api);
144
149
  }
145
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,16 +24,16 @@
24
24
  "dependencies": {
25
25
  "@rspack/plugin-react-refresh": "0.6.3",
26
26
  "react-refresh": "^0.14.0",
27
- "@rsbuild/shared": "0.6.6"
27
+ "@rsbuild/shared": "0.6.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "18.x",
31
31
  "typescript": "^5.4.2",
32
- "@rsbuild/core": "0.6.6",
33
- "@scripts/test-helper": "0.6.6"
32
+ "@rsbuild/core": "0.6.7",
33
+ "@scripts/test-helper": "0.6.7"
34
34
  },
35
35
  "peerDependencies": {
36
- "@rsbuild/core": "^0.6.6"
36
+ "@rsbuild/core": "^0.6.7"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",