@rsbuild/plugin-react 0.7.0-beta.2 → 0.7.0-beta.4

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
@@ -39,9 +39,23 @@ var import_shared3 = require("@rsbuild/shared");
39
39
  // src/react.ts
40
40
  var import_node_path = __toESM(require("path"));
41
41
  var import_shared = require("@rsbuild/shared");
42
+ var modifySwcLoaderOptions = ({
43
+ chain,
44
+ modifier
45
+ }) => {
46
+ const ruleIds = [import_shared.CHAIN_ID.RULE.JS, import_shared.CHAIN_ID.RULE.JS_DATA_URI];
47
+ for (const ruleId of ruleIds) {
48
+ if (chain.module.rules.has(ruleId)) {
49
+ const rule = chain.module.rule(ruleId);
50
+ if (rule.uses.has(import_shared.CHAIN_ID.USE.SWC)) {
51
+ rule.use(import_shared.CHAIN_ID.USE.SWC).tap(modifier);
52
+ }
53
+ }
54
+ }
55
+ };
42
56
  var applyBasicReactSupport = (api, options) => {
43
57
  const REACT_REFRESH_PATH = require.resolve("react-refresh");
44
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
58
+ api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID2, isDev, isProd: isProd2, target }) => {
45
59
  const config = api.getNormalizedConfig();
46
60
  const usingHMR = (0, import_shared.isUsingHMR)(config, { isProd: isProd2, target });
47
61
  const reactOptions = {
@@ -50,7 +64,7 @@ var applyBasicReactSupport = (api, options) => {
50
64
  runtime: "automatic",
51
65
  ...options.swcReactOptions
52
66
  };
53
- (0, import_shared.modifySwcLoaderOptions)({
67
+ modifySwcLoaderOptions({
54
68
  chain,
55
69
  modifier: (opts) => {
56
70
  const extraOptions = {
@@ -73,7 +87,7 @@ var applyBasicReactSupport = (api, options) => {
73
87
  }
74
88
  chain.resolve.alias.set("react-refresh", import_node_path.default.dirname(REACT_REFRESH_PATH));
75
89
  const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
76
- chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
90
+ chain.plugin(CHAIN_ID2.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
77
91
  {
78
92
  include: [import_shared.SCRIPT_REGEX],
79
93
  ...options.reactRefreshOptions
package/dist/index.js CHANGED
@@ -19,14 +19,28 @@ import { getNodeEnv } from "@rsbuild/shared";
19
19
  // src/react.ts
20
20
  import path2 from "path";
21
21
  import {
22
+ CHAIN_ID,
22
23
  SCRIPT_REGEX,
23
24
  deepmerge,
24
- isUsingHMR,
25
- modifySwcLoaderOptions
25
+ isUsingHMR
26
26
  } from "@rsbuild/shared";
27
+ var modifySwcLoaderOptions = ({
28
+ chain,
29
+ modifier
30
+ }) => {
31
+ const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI];
32
+ for (const ruleId of ruleIds) {
33
+ if (chain.module.rules.has(ruleId)) {
34
+ const rule = chain.module.rule(ruleId);
35
+ if (rule.uses.has(CHAIN_ID.USE.SWC)) {
36
+ rule.use(CHAIN_ID.USE.SWC).tap(modifier);
37
+ }
38
+ }
39
+ }
40
+ };
27
41
  var applyBasicReactSupport = (api, options) => {
28
42
  const REACT_REFRESH_PATH = __require.resolve("react-refresh");
29
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
43
+ api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID2, isDev, isProd: isProd2, target }) => {
30
44
  const config = api.getNormalizedConfig();
31
45
  const usingHMR = isUsingHMR(config, { isProd: isProd2, target });
32
46
  const reactOptions = {
@@ -58,7 +72,7 @@ var applyBasicReactSupport = (api, options) => {
58
72
  }
59
73
  chain.resolve.alias.set("react-refresh", path2.dirname(REACT_REFRESH_PATH));
60
74
  const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
61
- chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
75
+ chain.plugin(CHAIN_ID2.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
62
76
  {
63
77
  include: [SCRIPT_REGEX],
64
78
  ...options.reactRefreshOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.7.0-beta.2",
3
+ "version": "0.7.0-beta.4",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,18 +22,18 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@rspack/plugin-react-refresh": "0.6.5-canary-2456d69-20240515093621",
25
+ "@rspack/plugin-react-refresh": "0.7.0-beta.0",
26
26
  "react-refresh": "^0.14.2",
27
- "@rsbuild/shared": "0.7.0-beta.2"
27
+ "@rsbuild/shared": "0.7.0-beta.4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "18.x",
31
31
  "typescript": "^5.4.2",
32
- "@rsbuild/core": "0.7.0-beta.2",
33
- "@scripts/test-helper": "0.7.0-beta.2"
32
+ "@rsbuild/core": "0.7.0-beta.4",
33
+ "@scripts/test-helper": "0.7.0-beta.4"
34
34
  },
35
35
  "peerDependencies": {
36
- "@rsbuild/core": "^0.7.0-beta.2"
36
+ "@rsbuild/core": "^0.7.0-beta.4"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",