@rsbuild/plugin-react 0.0.0-nightly-20231024161008 → 0.0.8

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/antd.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import type { RsbuildTarget, SharedRsbuildPluginAPI } from '@rsbuild/shared';
2
- export declare const applyAntdSupport: (api: SharedRsbuildPluginAPI) => void;
3
- export declare function useSSR(target: RsbuildTarget | RsbuildTarget[]): boolean;
1
+ import { type SharedRsbuildPluginAPI } from '@rsbuild/shared';
2
+ export declare const applyAntdSupport: (api: SharedRsbuildPluginAPI) => void;
package/dist/antd.js CHANGED
@@ -18,11 +18,21 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var antd_exports = {};
20
20
  __export(antd_exports, {
21
- applyAntdSupport: () => applyAntdSupport,
22
- useSSR: () => useSSR
21
+ applyAntdSupport: () => applyAntdSupport
23
22
  });
24
23
  module.exports = __toCommonJS(antd_exports);
25
- var import_utils = require("@modern-js/utils");
24
+ var import_shared = require("@rsbuild/shared");
25
+ const getAntdMajorVersion = (appDirectory) => {
26
+ try {
27
+ const pkgJsonPath = require.resolve("antd/package.json", {
28
+ paths: [appDirectory]
29
+ });
30
+ const { version } = require(pkgJsonPath);
31
+ return Number(version.split(".")[0]);
32
+ } catch (err) {
33
+ return null;
34
+ }
35
+ };
26
36
  const applyAntdSupport = (api) => {
27
37
  api.modifyRsbuildConfig((rsbuildConfig) => {
28
38
  var _a, _b, _c;
@@ -32,27 +42,21 @@ const applyAntdSupport = (api) => {
32
42
  ))) {
33
43
  return;
34
44
  }
35
- const antdMajorVersion = (0, import_utils.getAntdMajorVersion)(api.context.rootPath);
45
+ const antdMajorVersion = getAntdMajorVersion(api.context.rootPath);
36
46
  if (antdMajorVersion && antdMajorVersion < 5) {
37
47
  (_c = rsbuildConfig.source) != null ? _c : rsbuildConfig.source = {};
38
48
  rsbuildConfig.source.transformImport = [
39
49
  ...rsbuildConfig.source.transformImport || [],
40
50
  {
41
51
  libraryName: "antd",
42
- libraryDirectory: useSSR(api.context.target) ? "lib" : "es",
52
+ libraryDirectory: (0, import_shared.useSSR)(api.context.target) ? "lib" : "es",
43
53
  style: true
44
54
  }
45
55
  ];
46
56
  }
47
57
  });
48
58
  };
49
- function useSSR(target) {
50
- return (Array.isArray(target) ? target : [target]).some(
51
- (item) => ["node", "service-worker"].includes(item)
52
- );
53
- }
54
59
  // Annotate the CommonJS export names for ESM import in node:
55
60
  0 && (module.exports = {
56
- applyAntdSupport,
57
- useSSR
61
+ applyAntdSupport
58
62
  });
package/dist/arco.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { SharedRsbuildPluginAPI } from '@rsbuild/shared';
1
+ import { type SharedRsbuildPluginAPI } from '@rsbuild/shared';
2
2
  export declare const applyArcoSupport: (api: SharedRsbuildPluginAPI) => void;
package/dist/arco.js CHANGED
@@ -21,17 +21,16 @@ __export(arco_exports, {
21
21
  applyArcoSupport: () => applyArcoSupport
22
22
  });
23
23
  module.exports = __toCommonJS(arco_exports);
24
- var import_utils = require("@modern-js/utils");
25
- var import_antd = require("./antd");
24
+ var import_shared = require("@rsbuild/shared");
26
25
  const applyArcoSupport = (api) => {
27
26
  const ARCO_NAME = "@arco-design/web-react";
28
27
  const ARCO_ICON = `${ARCO_NAME}/icon`;
29
28
  api.modifyRsbuildConfig((rsbuildConfig) => {
30
29
  const { transformImport = [] } = rsbuildConfig.source || {};
31
- if (transformImport === false || !(0, import_utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
30
+ if (transformImport === false || !(0, import_shared.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
32
31
  return;
33
32
  }
34
- const isUseSSR = (0, import_antd.useSSR)(api.context.target);
33
+ const isUseSSR = (0, import_shared.useSSR)(api.context.target);
35
34
  if (!(transformImport == null ? void 0 : transformImport.some((item) => item.libraryName === ARCO_NAME))) {
36
35
  transformImport.push({
37
36
  libraryName: ARCO_NAME,
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { SharedRsbuildPluginAPI } from '@rsbuild/shared';
1
+ import { type SharedRsbuildPluginAPI } from '@rsbuild/shared';
2
2
  export declare const applyBasicReactSupport: (api: SharedRsbuildPluginAPI) => void;
package/dist/react.js CHANGED
@@ -68,11 +68,10 @@ const applyRspack = (api) => {
68
68
  };
69
69
  const applyWebpack = (api) => {
70
70
  api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
71
- const { isBeyondReact17 } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
72
71
  const babelConfig = {
73
72
  tools: {
74
73
  babel(_, { addPresets, addPlugins }) {
75
- const isNewJsx = isBeyondReact17(api.context.rootPath);
74
+ const isNewJsx = (0, import_shared.isBeyondReact17)(api.context.rootPath);
76
75
  const presetReactOptions = {
77
76
  development: !(0, import_shared.isProd)(),
78
77
  // Will use the native built-in instead of trying to polyfill
@@ -1,3 +1,3 @@
1
- import { type SharedRsbuildPluginAPI, type CacheGroup } from '@rsbuild/shared';
1
+ import { type CacheGroup, type SharedRsbuildPluginAPI } from '@rsbuild/shared';
2
2
  export declare function splitByExperience(rootPath: string): Promise<CacheGroup>;
3
3
  export declare const applySplitChunksRule: (api: SharedRsbuildPluginAPI) => void;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var splitChunks_exports = {};
30
20
  __export(splitChunks_exports, {
@@ -33,8 +23,8 @@ __export(splitChunks_exports, {
33
23
  });
34
24
  module.exports = __toCommonJS(splitChunks_exports);
35
25
  var import_splitChunks = require("@rsbuild/core/plugins/splitChunks");
26
+ var import_shared = require("@rsbuild/shared");
36
27
  async function splitByExperience(rootPath) {
37
- const { isPackageInstalled } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
38
28
  const experienceCacheGroup = {};
39
29
  const packageRegExps = {
40
30
  react: (0, import_splitChunks.createDependenciesRegExp)("react", "react-dom", "scheduler"),
@@ -45,13 +35,13 @@ async function splitByExperience(rootPath) {
45
35
  "history"
46
36
  )
47
37
  };
48
- if (isPackageInstalled("antd", rootPath)) {
38
+ if ((0, import_shared.isPackageInstalled)("antd", rootPath)) {
49
39
  packageRegExps.antd = (0, import_splitChunks.createDependenciesRegExp)("antd");
50
40
  }
51
- if (isPackageInstalled("@arco-design/web-react", rootPath)) {
41
+ if ((0, import_shared.isPackageInstalled)("@arco-design/web-react", rootPath)) {
52
42
  packageRegExps.arco = (0, import_splitChunks.createDependenciesRegExp)(/@?arco-design/);
53
43
  }
54
- if (isPackageInstalled("@douyinfe/semi-ui", rootPath)) {
44
+ if ((0, import_shared.isPackageInstalled)("@douyinfe/semi-ui", rootPath)) {
55
45
  packageRegExps.semi = (0, import_splitChunks.createDependenciesRegExp)(
56
46
  /@(ies|douyinfe)[\\/]semi-.*/
57
47
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.0.0-nightly-20231024161008",
3
+ "version": "0.0.8",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,19 +20,18 @@
20
20
  ],
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@rspack/plugin-react-refresh": "0.3.8",
24
23
  "@babel/preset-react": "^7.22.15",
25
- "@modern-js/utils": "^2.37.1",
26
24
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
25
+ "@rspack/plugin-react-refresh": "0.3.8",
27
26
  "babel-plugin-transform-react-remove-prop-types": "0.4.24",
28
- "@rsbuild/shared": "0.0.0-nightly-20231024161008"
27
+ "@rsbuild/shared": "0.0.8"
29
28
  },
30
29
  "devDependencies": {
31
30
  "@types/node": "^16",
32
31
  "typescript": "^5",
33
- "@rsbuild/core": "0.0.0-nightly-20231024161008",
34
- "@rsbuild/test-helper": "0.0.0-nightly-20231024161008",
35
- "@rsbuild/webpack": "0.0.0-nightly-20231024161008"
32
+ "@rsbuild/test-helper": "0.0.8",
33
+ "@rsbuild/core": "0.0.8",
34
+ "@rsbuild/webpack": "0.0.8"
36
35
  },
37
36
  "publishConfig": {
38
37
  "registry": "https://registry.npmjs.org/",