@rsbuild/plugin-react 1.0.5 → 1.0.6

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.cjs CHANGED
@@ -22,7 +22,7 @@ function __webpack_require__(moduleId) {
22
22
  }
23
23
  /************************************************************************/ // webpack/runtime/compat_get_default_export
24
24
  (()=>{
25
- // getDefaultExport function for compatibility with non-harmony modules
25
+ // getDefaultExport function for compatibility with non-ESM modules
26
26
  __webpack_require__.n = function(module1) {
27
27
  var getter = module1 && module1.__esModule ? function() {
28
28
  return module1['default'];
@@ -120,8 +120,7 @@ const react_require = (0, external_node_module_namespaceObject.createRequire)(/*
120
120
  }());
121
121
  const applyBasicReactSupport = (api, options)=>{
122
122
  const REACT_REFRESH_PATH = options.fastRefresh ? react_require.resolve('react-refresh') : '';
123
- api.modifyEnvironmentConfig((config, param)=>{
124
- let { mergeEnvironmentConfig } = param;
123
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
125
124
  const isDev = 'development' === config.mode;
126
125
  const usingHMR = isDev && config.dev.hmr && 'web' === config.output.target;
127
126
  const reactOptions = {
@@ -148,8 +147,7 @@ const applyBasicReactSupport = (api, options)=>{
148
147
  };
149
148
  return mergeEnvironmentConfig(extraConfig, config);
150
149
  });
151
- api.modifyBundlerChain(async (chain, param)=>{
152
- let { CHAIN_ID, environment, isDev, target } = param;
150
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev, target })=>{
153
151
  const { config } = environment;
154
152
  const usingHMR = isDev && config.dev.hmr && 'web' === target;
155
153
  if (!usingHMR || !options.fastRefresh) return;
@@ -171,8 +169,7 @@ const applyBasicReactSupport = (api, options)=>{
171
169
  });
172
170
  };
173
171
  const applyReactProfiler = (api)=>{
174
- api.modifyEnvironmentConfig((config, param)=>{
175
- let { mergeEnvironmentConfig } = param;
172
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
176
173
  if ('production' !== config.mode) return;
177
174
  const enableProfilerConfig = {
178
175
  output: {
@@ -191,8 +188,7 @@ const applyReactProfiler = (api)=>{
191
188
  };
192
189
  return mergeEnvironmentConfig(config, enableProfilerConfig);
193
190
  });
194
- api.modifyBundlerChain((chain, param)=>{
195
- let { isProd } = param;
191
+ api.modifyBundlerChain((chain, { isProd })=>{
196
192
  if (!isProd) return;
197
193
  // Replace react-dom with the profiling version.
198
194
  // Reference: https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977
@@ -201,13 +197,11 @@ const applyReactProfiler = (api)=>{
201
197
  });
202
198
  };
203
199
  const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
204
- const applySplitChunksRule = function(api) {
205
- let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
206
- react: true,
207
- router: true
208
- };
209
- api.modifyBundlerChain((chain, param)=>{
210
- let { environment, isProd } = param;
200
+ const applySplitChunksRule = (api, options = {
201
+ react: true,
202
+ router: true
203
+ })=>{
204
+ api.modifyBundlerChain((chain, { environment, isProd })=>{
211
205
  const { config } = environment;
212
206
  if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
213
207
  const currentConfig = chain.optimization.splitChunks.values();
@@ -234,9 +228,7 @@ const applySplitChunksRule = function(api) {
234
228
  });
235
229
  };
236
230
  const PLUGIN_REACT_NAME = 'rsbuild:react';
237
- const pluginReact = function() {
238
- let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
239
- return {
231
+ const pluginReact = (options = {})=>({
240
232
  name: PLUGIN_REACT_NAME,
241
233
  setup (api) {
242
234
  const defaultOptions = {
@@ -253,8 +245,7 @@ const pluginReact = function() {
253
245
  }
254
246
  applySplitChunksRule(api, null == finalOptions ? void 0 : finalOptions.splitChunks);
255
247
  }
256
- };
257
- };
248
+ });
258
249
  var __webpack_export_target__ = exports;
259
250
  for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
260
251
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
package/dist/index.js CHANGED
@@ -3,8 +3,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
3
3
  const react_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
4
4
  const applyBasicReactSupport = (api, options)=>{
5
5
  const REACT_REFRESH_PATH = options.fastRefresh ? react_require.resolve('react-refresh') : '';
6
- api.modifyEnvironmentConfig((config, param)=>{
7
- let { mergeEnvironmentConfig } = param;
6
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
8
7
  const isDev = 'development' === config.mode;
9
8
  const usingHMR = isDev && config.dev.hmr && 'web' === config.output.target;
10
9
  const reactOptions = {
@@ -31,8 +30,7 @@ const applyBasicReactSupport = (api, options)=>{
31
30
  };
32
31
  return mergeEnvironmentConfig(extraConfig, config);
33
32
  });
34
- api.modifyBundlerChain(async (chain, param)=>{
35
- let { CHAIN_ID, environment, isDev, target } = param;
33
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev, target })=>{
36
34
  const { config } = environment;
37
35
  const usingHMR = isDev && config.dev.hmr && 'web' === target;
38
36
  if (!usingHMR || !options.fastRefresh) return;
@@ -54,8 +52,7 @@ const applyBasicReactSupport = (api, options)=>{
54
52
  });
55
53
  };
56
54
  const applyReactProfiler = (api)=>{
57
- api.modifyEnvironmentConfig((config, param)=>{
58
- let { mergeEnvironmentConfig } = param;
55
+ api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
59
56
  if ('production' !== config.mode) return;
60
57
  const enableProfilerConfig = {
61
58
  output: {
@@ -74,8 +71,7 @@ const applyReactProfiler = (api)=>{
74
71
  };
75
72
  return mergeEnvironmentConfig(config, enableProfilerConfig);
76
73
  });
77
- api.modifyBundlerChain((chain, param)=>{
78
- let { isProd } = param;
74
+ api.modifyBundlerChain((chain, { isProd })=>{
79
75
  if (!isProd) return;
80
76
  // Replace react-dom with the profiling version.
81
77
  // Reference: https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977
@@ -84,13 +80,11 @@ const applyReactProfiler = (api)=>{
84
80
  });
85
81
  };
86
82
  const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
87
- const applySplitChunksRule = function(api) {
88
- let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
89
- react: true,
90
- router: true
91
- };
92
- api.modifyBundlerChain((chain, param)=>{
93
- let { environment, isProd } = param;
83
+ const applySplitChunksRule = (api, options = {
84
+ react: true,
85
+ router: true
86
+ })=>{
87
+ api.modifyBundlerChain((chain, { environment, isProd })=>{
94
88
  const { config } = environment;
95
89
  if ('split-by-experience' !== config.performance.chunkSplit.strategy) return;
96
90
  const currentConfig = chain.optimization.splitChunks.values();
@@ -117,9 +111,7 @@ const applySplitChunksRule = function(api) {
117
111
  });
118
112
  };
119
113
  const PLUGIN_REACT_NAME = 'rsbuild:react';
120
- const pluginReact = function() {
121
- let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
122
- return {
114
+ const pluginReact = (options = {})=>({
123
115
  name: PLUGIN_REACT_NAME,
124
116
  setup (api) {
125
117
  const defaultOptions = {
@@ -136,6 +128,5 @@ const pluginReact = function() {
136
128
  }
137
129
  applySplitChunksRule(api, null == finalOptions ? void 0 : finalOptions.splitChunks);
138
130
  }
139
- };
140
- };
131
+ });
141
132
  export { PLUGIN_REACT_NAME, pluginReact };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,11 +28,11 @@
28
28
  "devDependencies": {
29
29
  "@types/node": "18.x",
30
30
  "typescript": "^5.6.3",
31
- "@rsbuild/core": "1.0.15",
31
+ "@rsbuild/core": "1.0.19",
32
32
  "@scripts/test-helper": "1.0.1"
33
33
  },
34
34
  "peerDependencies": {
35
- "@rsbuild/core": "1.x || ^1.0.1-rc.0"
35
+ "@rsbuild/core": "1.x"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",