@rsbuild/plugin-react 0.3.0 → 0.3.1

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.js CHANGED
@@ -156,27 +156,24 @@ var applyBasicReactSupport = (api, options) => {
156
156
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd2, target }) => {
157
157
  const config = api.getNormalizedConfig();
158
158
  const usingHMR = (0, import_shared4.isUsingHMR)(config, { isProd: isProd2, target });
159
- const rule = chain.module.rule(CHAIN_ID.RULE.JS);
160
159
  const reactOptions = {
161
160
  development: !isProd2,
162
161
  refresh: usingHMR,
163
162
  runtime: "automatic",
164
163
  ...options.swcReactOptions
165
164
  };
166
- rule.use(CHAIN_ID.USE.SWC).tap((options2) => {
167
- options2.jsc.transform.react = {
168
- ...reactOptions
169
- };
170
- return options2;
165
+ (0, import_shared4.modifySwcLoaderOptions)({
166
+ chain,
167
+ modifier: (options2) => {
168
+ return (0, import_shared4.deepmerge)(options2, {
169
+ jsc: {
170
+ transform: {
171
+ react: reactOptions
172
+ }
173
+ }
174
+ });
175
+ }
171
176
  });
172
- if (chain.module.rules.has(CHAIN_ID.RULE.JS_DATA_URI)) {
173
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).use(CHAIN_ID.USE.SWC).tap((options2) => {
174
- options2.jsc.transform.react = {
175
- ...reactOptions
176
- };
177
- return options2;
178
- });
179
- }
180
177
  if (!usingHMR) {
181
178
  return;
182
179
  }
package/dist/index.mjs CHANGED
@@ -135,34 +135,35 @@ var applySplitChunksRule = (api, options = {
135
135
 
136
136
  // src/react.ts
137
137
  import path2 from "path";
138
- import { isUsingHMR } from "@rsbuild/shared";
138
+ import {
139
+ deepmerge,
140
+ isUsingHMR,
141
+ modifySwcLoaderOptions
142
+ } from "@rsbuild/shared";
139
143
  var REACT_REFRESH_PATH = __require.resolve("react-refresh");
140
144
  var REACT_REFRESH_DIR_PATH = path2.dirname(REACT_REFRESH_PATH);
141
145
  var applyBasicReactSupport = (api, options) => {
142
146
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd2, target }) => {
143
147
  const config = api.getNormalizedConfig();
144
148
  const usingHMR = isUsingHMR(config, { isProd: isProd2, target });
145
- const rule = chain.module.rule(CHAIN_ID.RULE.JS);
146
149
  const reactOptions = {
147
150
  development: !isProd2,
148
151
  refresh: usingHMR,
149
152
  runtime: "automatic",
150
153
  ...options.swcReactOptions
151
154
  };
152
- rule.use(CHAIN_ID.USE.SWC).tap((options2) => {
153
- options2.jsc.transform.react = {
154
- ...reactOptions
155
- };
156
- return options2;
155
+ modifySwcLoaderOptions({
156
+ chain,
157
+ modifier: (options2) => {
158
+ return deepmerge(options2, {
159
+ jsc: {
160
+ transform: {
161
+ react: reactOptions
162
+ }
163
+ }
164
+ });
165
+ }
157
166
  });
158
- if (chain.module.rules.has(CHAIN_ID.RULE.JS_DATA_URI)) {
159
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).use(CHAIN_ID.USE.SWC).tap((options2) => {
160
- options2.jsc.transform.react = {
161
- ...reactOptions
162
- };
163
- return options2;
164
- });
165
- }
166
167
  if (!usingHMR) {
167
168
  return;
168
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,13 +24,13 @@
24
24
  "dependencies": {
25
25
  "@rspack/plugin-react-refresh": "0.5.0",
26
26
  "react-refresh": "^0.14.0",
27
- "@rsbuild/shared": "0.3.0"
27
+ "@rsbuild/shared": "0.3.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "16.x",
31
31
  "typescript": "^5.3.0",
32
- "@rsbuild/core": "0.3.0",
33
- "@rsbuild/test-helper": "0.3.0"
32
+ "@rsbuild/core": "0.3.1",
33
+ "@scripts/test-helper": "1.0.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public",