@rsbuild/plugin-react 0.0.19 → 0.0.21

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
@@ -261,11 +261,6 @@ var require_splitChunks = __commonJS({
261
261
  polyfill: config.output.polyfill
262
262
  });
263
263
  chain.optimization.splitChunks(splitChunksOptions);
264
- if (chunkSplit.strategy !== "all-in-one") {
265
- chain.optimization.runtimeChunk({
266
- name: import_shared5.RUNTIME_CHUNK_NAME
267
- });
268
- }
269
264
  }
270
265
  );
271
266
  }
@@ -355,7 +350,12 @@ var import_shared3 = require("@rsbuild/shared");
355
350
  async function splitByExperience(rootPath) {
356
351
  const experienceCacheGroup = {};
357
352
  const packageRegExps = {
358
- react: (0, import_splitChunks.createDependenciesRegExp)("react", "react-dom", "scheduler"),
353
+ react: (0, import_splitChunks.createDependenciesRegExp)(
354
+ "react",
355
+ "react-dom",
356
+ "scheduler",
357
+ ...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@pmmmwh/react-refresh-webpack-plugin"]
358
+ ),
359
359
  router: (0, import_splitChunks.createDependenciesRegExp)(
360
360
  "react-router",
361
361
  "react-router-dom",
@@ -441,12 +441,12 @@ var applyBasicReactSupport = (api) => {
441
441
  setupCompiler(multiCompiler);
442
442
  }
443
443
  });
444
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd2, target }) => {
444
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd3, target }) => {
445
445
  const config = api.getNormalizedConfig();
446
- const usingHMR = (0, import_shared4.isUsingHMR)(config, { isProd: isProd2, target });
446
+ const usingHMR = (0, import_shared4.isUsingHMR)(config, { isProd: isProd3, target });
447
447
  const rule = chain.module.rule(CHAIN_ID.RULE.JS);
448
448
  const reactOptions = {
449
- development: !isProd2,
449
+ development: !isProd3,
450
450
  refresh: usingHMR,
451
451
  runtime: "automatic"
452
452
  };
package/dist/index.mjs CHANGED
@@ -285,11 +285,6 @@ var require_splitChunks = __commonJS({
285
285
  polyfill: config.output.polyfill
286
286
  });
287
287
  chain.optimization.splitChunks(splitChunksOptions);
288
- if (chunkSplit.strategy !== "all-in-one") {
289
- chain.optimization.runtimeChunk({
290
- name: import_shared5.RUNTIME_CHUNK_NAME
291
- });
292
- }
293
288
  }
294
289
  );
295
290
  }
@@ -381,12 +376,18 @@ init_esm();
381
376
  init_require_shims();
382
377
  var import_splitChunks = __toESM(require_splitChunks());
383
378
  import {
379
+ isProd,
384
380
  isPackageInstalled as isPackageInstalled2
385
381
  } from "@rsbuild/shared";
386
382
  async function splitByExperience(rootPath) {
387
383
  const experienceCacheGroup = {};
388
384
  const packageRegExps = {
389
- react: (0, import_splitChunks.createDependenciesRegExp)("react", "react-dom", "scheduler"),
385
+ react: (0, import_splitChunks.createDependenciesRegExp)(
386
+ "react",
387
+ "react-dom",
388
+ "scheduler",
389
+ ...isProd() ? [] : ["react-refresh", "@pmmmwh/react-refresh-webpack-plugin"]
390
+ ),
390
391
  router: (0, import_splitChunks.createDependenciesRegExp)(
391
392
  "react-router",
392
393
  "react-router-dom",
@@ -437,7 +438,7 @@ var applySplitChunksRule = (api) => {
437
438
  // src/react.ts
438
439
  init_esm();
439
440
  init_require_shims();
440
- import { isUsingHMR, isClientCompiler, isProd } from "@rsbuild/shared";
441
+ import { isUsingHMR, isClientCompiler, isProd as isProd2 } from "@rsbuild/shared";
441
442
  function getReactRefreshEntry(compiler) {
442
443
  const hot = compiler.options.devServer?.hot ?? true;
443
444
  const refresh = compiler.options.builtins?.react?.refresh ?? true;
@@ -466,7 +467,7 @@ var setupCompiler = (compiler) => {
466
467
  };
467
468
  var applyBasicReactSupport = (api) => {
468
469
  api.onAfterCreateCompiler(({ compiler: multiCompiler }) => {
469
- if (isProd()) {
470
+ if (isProd2()) {
470
471
  return;
471
472
  }
472
473
  if (multiCompiler.compilers) {
@@ -475,12 +476,12 @@ var applyBasicReactSupport = (api) => {
475
476
  setupCompiler(multiCompiler);
476
477
  }
477
478
  });
478
- api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd2, target }) => {
479
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd3, target }) => {
479
480
  const config = api.getNormalizedConfig();
480
- const usingHMR = isUsingHMR(config, { isProd: isProd2, target });
481
+ const usingHMR = isUsingHMR(config, { isProd: isProd3, target });
481
482
  const rule = chain.module.rule(CHAIN_ID.RULE.JS);
482
483
  const reactOptions = {
483
- development: !isProd2,
484
+ development: !isProd3,
484
485
  refresh: usingHMR,
485
486
  runtime: "automatic"
486
487
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-react",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "React plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,13 +23,13 @@
23
23
  "dependencies": {
24
24
  "@rspack/plugin-react-refresh": "0.3.11",
25
25
  "react-refresh": "^0.14.0",
26
- "@rsbuild/shared": "0.0.19"
26
+ "@rsbuild/shared": "0.0.21"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^16",
30
30
  "typescript": "^5.2.2",
31
- "@rsbuild/core": "0.0.19",
32
- "@rsbuild/test-helper": "0.0.19"
31
+ "@rsbuild/core": "0.0.21",
32
+ "@rsbuild/test-helper": "0.0.21"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public",