@rsbuild/plugin-react 0.0.0-next-20240514150515 → 0.0.0-next-20240528072128

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,6 +39,21 @@ 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
+ CHAIN_ID,
45
+ modifier
46
+ }) => {
47
+ const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI];
48
+ for (const ruleId of ruleIds) {
49
+ if (chain.module.rules.has(ruleId)) {
50
+ const rule = chain.module.rule(ruleId);
51
+ if (rule.uses.has(CHAIN_ID.USE.SWC)) {
52
+ rule.use(CHAIN_ID.USE.SWC).tap(modifier);
53
+ }
54
+ }
55
+ }
56
+ };
42
57
  var applyBasicReactSupport = (api, options) => {
43
58
  const REACT_REFRESH_PATH = require.resolve("react-refresh");
44
59
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
@@ -50,8 +65,9 @@ var applyBasicReactSupport = (api, options) => {
50
65
  runtime: "automatic",
51
66
  ...options.swcReactOptions
52
67
  };
53
- (0, import_shared.modifySwcLoaderOptions)({
68
+ modifySwcLoaderOptions({
54
69
  chain,
70
+ CHAIN_ID,
55
71
  modifier: (opts) => {
56
72
  const extraOptions = {
57
73
  jsc: {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
2
- import type { PluginOptions as ReactRefreshOptions } from '@rspack/plugin-react-refresh';
3
- export type SplitReactChunkOptions = {
1
+ import { Rspack, RsbuildPlugin } from '@rsbuild/core';
2
+ import { PluginOptions } from '@rspack/plugin-react-refresh';
3
+
4
+ type SplitReactChunkOptions = {
4
5
  /**
5
6
  * Whether to enable split chunking for React-related dependencies (e.g., react, react-dom, scheduler).
6
7
  *
@@ -14,7 +15,7 @@ export type SplitReactChunkOptions = {
14
15
  */
15
16
  router?: boolean;
16
17
  };
17
- export type PluginReactOptions = {
18
+ type PluginReactOptions = {
18
19
  /**
19
20
  * Configure the behavior of SWC to transform React code,
20
21
  * the same as SWC's [jsc.transform.react](https://swc.rs/docs/configuration/compilation#jsctransformreact).
@@ -33,7 +34,9 @@ export type PluginReactOptions = {
33
34
  * Options passed to `@rspack/plugin-react-refresh`
34
35
  * @see https://rspack.dev/guide/tech/react#rspackplugin-react-refresh
35
36
  */
36
- reactRefreshOptions?: ReactRefreshOptions;
37
+ reactRefreshOptions?: PluginOptions;
37
38
  };
38
- export declare const PLUGIN_REACT_NAME = "rsbuild:react";
39
- export declare const pluginReact: ({ enableProfiler, ...options }?: PluginReactOptions) => RsbuildPlugin;
39
+ declare const PLUGIN_REACT_NAME = "rsbuild:react";
40
+ declare const pluginReact: ({ enableProfiler, ...options }?: PluginReactOptions) => RsbuildPlugin;
41
+
42
+ export { PLUGIN_REACT_NAME, type PluginReactOptions, type SplitReactChunkOptions, pluginReact };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  throw Error('Dynamic require of "' + x + '" is not supported');
10
10
  });
11
11
 
12
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.50.0_eslint@9.3.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
13
  import { fileURLToPath } from "url";
14
14
  import path from "path";
15
15
 
@@ -18,12 +18,22 @@ import { getNodeEnv } from "@rsbuild/shared";
18
18
 
19
19
  // src/react.ts
20
20
  import path2 from "path";
21
- import {
22
- SCRIPT_REGEX,
23
- deepmerge,
24
- isUsingHMR,
25
- modifySwcLoaderOptions
26
- } from "@rsbuild/shared";
21
+ import { SCRIPT_REGEX, deepmerge, isUsingHMR } from "@rsbuild/shared";
22
+ var modifySwcLoaderOptions = ({
23
+ chain,
24
+ CHAIN_ID,
25
+ modifier
26
+ }) => {
27
+ const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI];
28
+ for (const ruleId of ruleIds) {
29
+ if (chain.module.rules.has(ruleId)) {
30
+ const rule = chain.module.rule(ruleId);
31
+ if (rule.uses.has(CHAIN_ID.USE.SWC)) {
32
+ rule.use(CHAIN_ID.USE.SWC).tap(modifier);
33
+ }
34
+ }
35
+ }
36
+ };
27
37
  var applyBasicReactSupport = (api, options) => {
28
38
  const REACT_REFRESH_PATH = __require.resolve("react-refresh");
29
39
  api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
@@ -37,6 +47,7 @@ var applyBasicReactSupport = (api, options) => {
37
47
  };
38
48
  modifySwcLoaderOptions({
39
49
  chain,
50
+ CHAIN_ID,
40
51
  modifier: (opts) => {
41
52
  const extraOptions = {
42
53
  jsc: {
@@ -90,11 +101,7 @@ var applyReactProfiler = (api) => {
90
101
  };
91
102
 
92
103
  // src/splitChunks.ts
93
- import {
94
- createCacheGroups,
95
- isPlainObject,
96
- isProd
97
- } from "@rsbuild/shared";
104
+ import { createCacheGroups, isPlainObject, isProd } from "@rsbuild/shared";
98
105
  var applySplitChunksRule = (api, options = {
99
106
  react: true,
100
107
  router: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.0.0-next-20240514150515",
3
+ "version": "0.0.0-next-20240528072128",
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",
25
+ "@rspack/plugin-react-refresh": "0.7.0",
26
26
  "react-refresh": "^0.14.2",
27
- "@rsbuild/shared": "0.0.0-next-20240514150515"
27
+ "@rsbuild/shared": "0.0.0-next-20240528072128"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "18.x",
31
31
  "typescript": "^5.4.2",
32
- "@rsbuild/core": "0.0.0-next-20240514150515",
33
- "@scripts/test-helper": "0.0.0-next-20240514150515"
32
+ "@rsbuild/core": "0.0.0-next-20240528072128",
33
+ "@scripts/test-helper": "0.0.0-next-20240528072128"
34
34
  },
35
35
  "peerDependencies": {
36
- "@rsbuild/core": "0.0.0-next-20240514150515"
36
+ "@rsbuild/core": "0.0.0-next-20240528072128"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",
package/dist/react.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { RsbuildPluginAPI } from '@rsbuild/core';
2
- import type { PluginReactOptions } from '.';
3
- export declare const applyBasicReactSupport: (api: RsbuildPluginAPI, options: PluginReactOptions) => void;
4
- export declare const applyReactProfiler: (api: RsbuildPluginAPI) => void;
@@ -1,3 +0,0 @@
1
- import type { RsbuildPluginAPI } from '@rsbuild/core';
2
- import type { SplitReactChunkOptions } from '.';
3
- export declare const applySplitChunksRule: (api: RsbuildPluginAPI, options?: SplitReactChunkOptions) => void;