@rsbuild/plugin-react 0.0.0-next-20231207110454 → 0.0.0-next-20240104101129

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,12 +1,25 @@
1
1
  import { RsbuildPlugin } from '@rsbuild/core';
2
2
 
3
- declare const isBeyondReact17: (cwd: string) => Promise<boolean>;
3
+ declare const isBeyondReact17: (cwd: string) => Promise<any>;
4
4
 
5
5
  type SplitReactChunkOptions = {
6
+ /**
7
+ * Whether to enable split chunking for React-related dependencies (e.g., react, react-dom, scheduler).
8
+ *
9
+ * @default true
10
+ */
6
11
  react?: boolean;
12
+ /**
13
+ * Whether to enable split chunking for routing-related dependencies (e.g., react-router, react-router-dom, history).
14
+ *
15
+ * @default true
16
+ */
7
17
  router?: boolean;
8
18
  };
9
19
  type PluginReactOptions = {
20
+ /**
21
+ * Configuration for chunk splitting of React-related dependencies.
22
+ */
10
23
  splitChunks?: SplitReactChunkOptions;
11
24
  };
12
25
  declare const pluginReact: (options?: PluginReactOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -63,7 +63,7 @@ var applyAntdSupport = (api) => {
63
63
  ...rsbuildConfig.source.transformImport || [],
64
64
  {
65
65
  libraryName: "antd",
66
- libraryDirectory: (0, import_shared.isServerTarget)(api.context.target) ? "lib" : "es",
66
+ libraryDirectory: (0, import_shared.isServerTarget)(api.context.targets) ? "lib" : "es",
67
67
  style: true
68
68
  }
69
69
  ];
@@ -81,7 +81,7 @@ var applyArcoSupport = (api) => {
81
81
  if (transformImport === false || !(0, import_shared2.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
82
82
  return;
83
83
  }
84
- const isUseSSR = (0, import_shared2.isServerTarget)(api.context.target);
84
+ const isUseSSR = (0, import_shared2.isServerTarget)(api.context.targets);
85
85
  if (!transformImport?.some((item) => item.libraryName === ARCO_NAME)) {
86
86
  transformImport.push({
87
87
  libraryName: ARCO_NAME,
@@ -123,15 +123,15 @@ var applySplitChunksRule = (api, options = {
123
123
  "react",
124
124
  "react-dom",
125
125
  "scheduler",
126
- ...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
126
+ ...(0, import_shared3.isProd)() ? [] : ["react-refresh", /@rspack[\\/]plugin-react-refresh/]
127
127
  ];
128
128
  }
129
129
  if (options.router) {
130
130
  extraGroups.router = [
131
131
  "react-router",
132
132
  "react-router-dom",
133
- "@remix-run/router",
134
- "history"
133
+ "history",
134
+ /@remix-run[\\/]router/
135
135
  ];
136
136
  }
137
137
  if (!Object.keys(extraGroups).length) {
@@ -166,12 +166,9 @@ var setupCompiler = (compiler) => {
166
166
  if (!reactRefreshEntry) {
167
167
  return;
168
168
  }
169
- for (const key in compiler.options.entry) {
170
- compiler.options.entry[key].import = [
171
- reactRefreshEntry,
172
- ...compiler.options.entry[key].import || []
173
- ];
174
- }
169
+ new compiler.webpack.EntryPlugin(compiler.context, reactRefreshEntry, {
170
+ name: void 0
171
+ }).apply(compiler);
175
172
  };
176
173
  var applyBasicReactSupport = (api) => {
177
174
  api.onAfterCreateCompiler(({ compiler: multiCompiler }) => {
@@ -217,7 +214,7 @@ var applyBasicReactSupport = (api) => {
217
214
 
218
215
  // src/utils.ts
219
216
  var import_fs = __toESM(require("fs"));
220
- var import_semver = __toESM(require("semver"));
217
+ var import_semver = __toESM(require("@rsbuild/shared/semver"));
221
218
  var import_shared5 = require("@rsbuild/shared");
222
219
  var isBeyondReact17 = async (cwd) => {
223
220
  const pkgPath = await (0, import_shared5.findUp)({ cwd, filename: "package.json" });
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.41.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
9
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.45.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
10
10
  import { fileURLToPath } from "url";
11
11
  import path from "path";
12
12
 
@@ -42,7 +42,7 @@ var applyAntdSupport = (api) => {
42
42
  ...rsbuildConfig.source.transformImport || [],
43
43
  {
44
44
  libraryName: "antd",
45
- libraryDirectory: isServerTarget(api.context.target) ? "lib" : "es",
45
+ libraryDirectory: isServerTarget(api.context.targets) ? "lib" : "es",
46
46
  style: true
47
47
  }
48
48
  ];
@@ -63,7 +63,7 @@ var applyArcoSupport = (api) => {
63
63
  if (transformImport === false || !isPackageInstalled(ARCO_NAME, api.context.rootPath)) {
64
64
  return;
65
65
  }
66
- const isUseSSR = isServerTarget2(api.context.target);
66
+ const isUseSSR = isServerTarget2(api.context.targets);
67
67
  if (!transformImport?.some((item) => item.libraryName === ARCO_NAME)) {
68
68
  transformImport.push({
69
69
  libraryName: ARCO_NAME,
@@ -109,15 +109,15 @@ var applySplitChunksRule = (api, options = {
109
109
  "react",
110
110
  "react-dom",
111
111
  "scheduler",
112
- ...isProd() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
112
+ ...isProd() ? [] : ["react-refresh", /@rspack[\\/]plugin-react-refresh/]
113
113
  ];
114
114
  }
115
115
  if (options.router) {
116
116
  extraGroups.router = [
117
117
  "react-router",
118
118
  "react-router-dom",
119
- "@remix-run/router",
120
- "history"
119
+ "history",
120
+ /@remix-run[\\/]router/
121
121
  ];
122
122
  }
123
123
  if (!Object.keys(extraGroups).length) {
@@ -154,12 +154,9 @@ var setupCompiler = (compiler) => {
154
154
  if (!reactRefreshEntry) {
155
155
  return;
156
156
  }
157
- for (const key in compiler.options.entry) {
158
- compiler.options.entry[key].import = [
159
- reactRefreshEntry,
160
- ...compiler.options.entry[key].import || []
161
- ];
162
- }
157
+ new compiler.webpack.EntryPlugin(compiler.context, reactRefreshEntry, {
158
+ name: void 0
159
+ }).apply(compiler);
163
160
  };
164
161
  var applyBasicReactSupport = (api) => {
165
162
  api.onAfterCreateCompiler(({ compiler: multiCompiler }) => {
@@ -205,7 +202,7 @@ var applyBasicReactSupport = (api) => {
205
202
 
206
203
  // src/utils.ts
207
204
  import fs from "fs";
208
- import semver from "semver";
205
+ import semver from "@rsbuild/shared/semver";
209
206
  import { findUp } from "@rsbuild/shared";
210
207
  var isBeyondReact17 = async (cwd) => {
211
208
  const pkgPath = await findUp({ cwd, filename: "package.json" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.0.0-next-20231207110454",
3
+ "version": "0.0.0-next-20240104101129",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,17 +22,15 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@rspack/plugin-react-refresh": "0.4.2",
25
+ "@rspack/plugin-react-refresh": "0.4.5",
26
26
  "react-refresh": "^0.14.0",
27
- "semver": "^7.5.4",
28
- "@rsbuild/shared": "0.0.0-next-20231207110454"
27
+ "@rsbuild/shared": "0.0.0-next-20240104101129"
29
28
  },
30
29
  "devDependencies": {
31
- "@types/node": "^16",
32
- "@types/semver": "^7.5.4",
30
+ "@types/node": "16.x",
33
31
  "typescript": "^5.3.0",
34
- "@rsbuild/core": "0.0.0-next-20231207110454",
35
- "@rsbuild/test-helper": "0.0.0-next-20231207110454"
32
+ "@rsbuild/core": "0.0.0-next-20240104101129",
33
+ "@rsbuild/test-helper": "0.0.0-next-20240104101129"
36
34
  },
37
35
  "publishConfig": {
38
36
  "access": "public",