@rsbuild/plugin-react 0.1.9 → 0.2.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
@@ -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,
@@ -104,33 +104,29 @@ var applyArcoSupport = (api) => {
104
104
 
105
105
  // src/splitChunks.ts
106
106
  var import_shared3 = require("@rsbuild/shared");
107
- var applySplitChunksRule = (api, options) => {
107
+ var applySplitChunksRule = (api, options = {
108
+ react: true,
109
+ router: true
110
+ }) => {
108
111
  api.modifyBundlerChain((chain) => {
109
112
  const config = api.getNormalizedConfig();
110
- const { chunkSplit } = config.performance || {};
111
- if (chunkSplit?.strategy !== "split-by-experience") {
113
+ if (config.performance.chunkSplit.strategy !== "split-by-experience") {
112
114
  return;
113
115
  }
114
- if (!options) {
115
- options = {
116
- react: true,
117
- router: true
118
- };
119
- }
120
116
  const currentConfig = chain.optimization.splitChunks.values();
121
117
  if (!(0, import_shared3.isPlainObject)(currentConfig)) {
122
118
  return;
123
119
  }
124
120
  const extraGroups = {};
125
- if (options.react !== false) {
121
+ if (options.react) {
126
122
  extraGroups.react = [
127
123
  "react",
128
124
  "react-dom",
129
125
  "scheduler",
130
- ...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@pmmmwh/react-refresh-webpack-plugin"]
126
+ ...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
131
127
  ];
132
128
  }
133
- if (options.router !== false) {
129
+ if (options.router) {
134
130
  extraGroups.router = [
135
131
  "react-router",
136
132
  "react-router-dom",
package/dist/index.mjs CHANGED
@@ -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,
@@ -90,33 +90,29 @@ import {
90
90
  isPlainObject,
91
91
  createCacheGroups
92
92
  } from "@rsbuild/shared";
93
- var applySplitChunksRule = (api, options) => {
93
+ var applySplitChunksRule = (api, options = {
94
+ react: true,
95
+ router: true
96
+ }) => {
94
97
  api.modifyBundlerChain((chain) => {
95
98
  const config = api.getNormalizedConfig();
96
- const { chunkSplit } = config.performance || {};
97
- if (chunkSplit?.strategy !== "split-by-experience") {
99
+ if (config.performance.chunkSplit.strategy !== "split-by-experience") {
98
100
  return;
99
101
  }
100
- if (!options) {
101
- options = {
102
- react: true,
103
- router: true
104
- };
105
- }
106
102
  const currentConfig = chain.optimization.splitChunks.values();
107
103
  if (!isPlainObject(currentConfig)) {
108
104
  return;
109
105
  }
110
106
  const extraGroups = {};
111
- if (options.react !== false) {
107
+ if (options.react) {
112
108
  extraGroups.react = [
113
109
  "react",
114
110
  "react-dom",
115
111
  "scheduler",
116
- ...isProd() ? [] : ["react-refresh", "@pmmmwh/react-refresh-webpack-plugin"]
112
+ ...isProd() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
117
113
  ];
118
114
  }
119
- if (options.router !== false) {
115
+ if (options.router) {
120
116
  extraGroups.router = [
121
117
  "react-router",
122
118
  "react-router-dom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,17 +22,17 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@rspack/plugin-react-refresh": "0.4.1-canary-10d4cb5-20231204024139",
25
+ "@rspack/plugin-react-refresh": "0.4.2",
26
26
  "react-refresh": "^0.14.0",
27
27
  "semver": "^7.5.4",
28
- "@rsbuild/shared": "0.1.9"
28
+ "@rsbuild/shared": "0.2.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^16",
31
+ "@types/node": "16.x",
32
32
  "@types/semver": "^7.5.4",
33
33
  "typescript": "^5.3.0",
34
- "@rsbuild/core": "0.1.9",
35
- "@rsbuild/test-helper": "0.1.9"
34
+ "@rsbuild/test-helper": "0.2.1",
35
+ "@rsbuild/core": "0.2.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",