@lynx-js/react-rsbuild-plugin 0.15.0 → 0.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @lynx-js/react-rsbuild-plugin
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Respect `dev.hmr: false` when installing React Refresh integrations so disabled HMR no longer injects the refresh loader or plugin. ([#2487](https://github.com/lynx-family/lynx-stack/pull/2487))
8
+
9
+ - Fix stale callback-local references when transforming JSX inside `children={array.map(...)}` prop expressions. ([#2524](https://github.com/lynx-family/lynx-stack/pull/2524))
10
+
11
+ - Supports @lynx-js/react 0.120.0 ([#1764](https://github.com/lynx-family/lynx-stack/pull/1764))
12
+
13
+ - Updated dependencies [[`e179680`](https://github.com/lynx-family/lynx-stack/commit/e1796803444ba70efa86609b620c3a753b6694de), [`13655ac`](https://github.com/lynx-family/lynx-stack/commit/13655ac8f156ab887de2f527b34c865574ebe6e6), [`f15494b`](https://github.com/lynx-family/lynx-stack/commit/f15494b3b1231c11facd61bf1e07a43b6df5e07c), [`e179680`](https://github.com/lynx-family/lynx-stack/commit/e1796803444ba70efa86609b620c3a753b6694de), [`e179680`](https://github.com/lynx-family/lynx-stack/commit/e1796803444ba70efa86609b620c3a753b6694de)]:
14
+ - @lynx-js/template-webpack-plugin@0.11.0
15
+ - @lynx-js/css-extract-webpack-plugin@0.7.1
16
+ - @lynx-js/react-webpack-plugin@0.9.2
17
+ - @lynx-js/react-alias-rsbuild-plugin@0.16.1
18
+ - @lynx-js/use-sync-external-store@1.5.0
19
+ - @lynx-js/react-refresh-webpack-plugin@0.3.5
20
+
21
+ ## 0.16.0
22
+
23
+ ### Minor Changes
24
+
25
+ - Simplify hooks for main-thread runtime, which only can run during the first screen. ([#2441](https://github.com/lynx-family/lynx-stack/pull/2441))
26
+
27
+ ### Patch Changes
28
+
29
+ - Support rstest for testing library using a dedicated testing loader. ([#2328](https://github.com/lynx-family/lynx-stack/pull/2328))
30
+
31
+ - Fix `environments.lynx.performance.profile` so it overrides the default profile behavior for the current environment. ([#2468](https://github.com/lynx-family/lynx-stack/pull/2468))
32
+
33
+ - Add `enableUiSourceMap` option to enable UI source map generation and debug-metadata asset emission. ([#2402](https://github.com/lynx-family/lynx-stack/pull/2402))
34
+
35
+ - Updated dependencies [[`a9f8d05`](https://github.com/lynx-family/lynx-stack/commit/a9f8d0548664ea32ebae2072c13f2cf6fee676eb), [`b1ad1b9`](https://github.com/lynx-family/lynx-stack/commit/b1ad1b98ed8d4635ad89fac42fe2fbb7e8e56c39), [`f6184f3`](https://github.com/lynx-family/lynx-stack/commit/f6184f32c3eb160d16ee852da4955765b5ad1398), [`f6184f3`](https://github.com/lynx-family/lynx-stack/commit/f6184f32c3eb160d16ee852da4955765b5ad1398), [`a9f8d05`](https://github.com/lynx-family/lynx-stack/commit/a9f8d0548664ea32ebae2072c13f2cf6fee676eb), [`f542d9c`](https://github.com/lynx-family/lynx-stack/commit/f542d9c98b376d340443b4683ed0c7707beeb5ad)]:
36
+ - @lynx-js/template-webpack-plugin@0.10.9
37
+ - @lynx-js/react-webpack-plugin@0.9.1
38
+ - @lynx-js/react-alias-rsbuild-plugin@0.16.0
39
+ - @lynx-js/css-extract-webpack-plugin@0.7.0
40
+ - @lynx-js/react-refresh-webpack-plugin@0.3.5
41
+ - @lynx-js/use-sync-external-store@1.5.0
42
+
3
43
  ## 0.15.0
4
44
 
5
45
  ### Minor Changes
package/dist/208.js CHANGED
@@ -6,7 +6,7 @@ import { LynxEncodePlugin, LynxTemplatePlugin, WebEncodePlugin } from "@lynx-js/
6
6
  import node_path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { RuntimeWrapperWebpackPlugin } from "@lynx-js/runtime-wrapper-webpack-plugin";
9
- import { ReactRefreshRspackPlugin } from "@lynx-js/react-refresh-webpack-plugin";
9
+ import { ReactRefreshRspackPlugin, ReactRefreshWebpackPlugin } from "@lynx-js/react-refresh-webpack-plugin";
10
10
  __webpack_require__.add({
11
11
  "../../../node_modules/.pnpm/typia@10.1.0_typescript@5.9.3/node_modules/typia/lib/internal/_accessExpressionAsString.js" (__unused_rspack_module, exports) {
12
12
  exports._accessExpressionAsString = void 0;
@@ -325,7 +325,10 @@ function applyEntry(api, options) {
325
325
  }
326
326
  ]);
327
327
  function getDefaultProfile() {
328
- if (userConfig.performance?.profile !== void 0) return userConfig.performance.profile;
328
+ const environmentProfile = userConfig.environments?.[environment.name]?.performance?.profile;
329
+ if (void 0 !== environmentProfile) return environmentProfile;
330
+ const userProfile = userConfig.performance?.profile;
331
+ if (void 0 !== userProfile) return userProfile;
329
332
  if (isDebug()) return true;
330
333
  }
331
334
  });
@@ -392,22 +395,36 @@ function applyLazy(api) {
392
395
  });
393
396
  });
394
397
  }
398
+ function getLoaderOptions(api, options, isMainThread = false) {
399
+ const { output } = api.getRsbuildConfig();
400
+ const inlineSourcesContent = output?.sourceMap === true || !(output?.sourceMap === false || output?.sourceMap?.js === false || output?.sourceMap?.js?.includes('nosources'));
401
+ const { compat, enableRemoveCSSScope, shake, defineDCE, engineVersion, enableUiSourceMap, experimental_isLazyBundle } = options;
402
+ return {
403
+ compat,
404
+ enableRemoveCSSScope,
405
+ isDynamicComponent: experimental_isLazyBundle,
406
+ inlineSourcesContent,
407
+ defineDCE,
408
+ engineVersion,
409
+ ...isMainThread ? {
410
+ enableUiSourceMap,
411
+ shake
412
+ } : {}
413
+ };
414
+ }
415
+ const TESTING_RULE_NAME = 'react:testing';
416
+ function applyTestingLoaders(api, options) {
417
+ api.modifyBundlerChain((chain, { CHAIN_ID })=>{
418
+ const rule = chain.module.rules.get(CHAIN_ID.RULE.JS);
419
+ rule.use(TESTING_RULE_NAME).loader(ReactWebpackPlugin.loaders.TESTING).options(getLoaderOptions(api, options)).end();
420
+ });
421
+ }
395
422
  function applyLoaders(api, options) {
396
- const { compat, enableRemoveCSSScope, shake, defineDCE, engineVersion, experimental_isLazyBundle } = options;
397
423
  api.modifyBundlerChain((chain, { CHAIN_ID })=>{
398
424
  const rule = chain.module.rules.get(CHAIN_ID.RULE.JS);
399
425
  const uses = rule.uses.entries() ?? {};
400
- const { output } = api.getRsbuildConfig();
401
- const inlineSourcesContent = output?.sourceMap === true || !(output?.sourceMap === false || output?.sourceMap?.js === false || output?.sourceMap?.js?.includes('nosources'));
402
426
  const backgroundRule = rule.oneOf(LAYERS.BACKGROUND);
403
- backgroundRule.issuerLayer(LAYERS.BACKGROUND).uses.merge(uses).end().use(LAYERS.BACKGROUND).loader(ReactWebpackPlugin.loaders.BACKGROUND).options({
404
- compat,
405
- enableRemoveCSSScope,
406
- isDynamicComponent: experimental_isLazyBundle,
407
- inlineSourcesContent,
408
- defineDCE,
409
- engineVersion
410
- }).end();
427
+ backgroundRule.issuerLayer(LAYERS.BACKGROUND).uses.merge(uses).end().use(LAYERS.BACKGROUND).loader(ReactWebpackPlugin.loaders.BACKGROUND).options(getLoaderOptions(api, options)).end();
411
428
  const mainThreadRule = rule.oneOf(LAYERS.MAIN_THREAD);
412
429
  mainThreadRule.issuerLayer(LAYERS.MAIN_THREAD).uses.merge(uses).end().when(void 0 !== uses[CHAIN_ID.USE.SWC], (rule)=>{
413
430
  rule.uses.delete(CHAIN_ID.USE.SWC);
@@ -420,15 +437,7 @@ function applyLoaders(api, options) {
420
437
  target: 'es2019'
421
438
  }
422
439
  });
423
- }).use(LAYERS.MAIN_THREAD).loader(ReactWebpackPlugin.loaders.MAIN_THREAD).options({
424
- compat,
425
- enableRemoveCSSScope,
426
- inlineSourcesContent,
427
- isDynamicComponent: experimental_isLazyBundle,
428
- engineVersion,
429
- shake,
430
- defineDCE
431
- }).end();
440
+ }).use(LAYERS.MAIN_THREAD).loader(ReactWebpackPlugin.loaders.MAIN_THREAD).options(getLoaderOptions(api, options, true)).end();
432
441
  rule.uses.clear();
433
442
  });
434
443
  }
@@ -480,8 +489,11 @@ function applyOptimizeBundleSize(api, options) {
480
489
  }
481
490
  const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh';
482
491
  function applyRefresh(api) {
483
- api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID })=>{
484
- if (!isProd) {
492
+ api.modifyWebpackChain?.(async (chain, { CHAIN_ID, environment, isProd })=>{
493
+ if (!isProd && environment.config.dev?.hmr !== false) await applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshWebpackPlugin);
494
+ });
495
+ api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID, environment })=>{
496
+ if (!isProd && environment.config.dev?.hmr !== false) {
485
497
  const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
486
498
  await Promise.all([
487
499
  applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshRspackPlugin),
@@ -595,8 +607,9 @@ function applyUseSyncExternalStore(api) {
595
607
  const _assertGuard = __webpack_require__("../../../node_modules/.pnpm/typia@10.1.0_typescript@5.9.3/node_modules/typia/lib/internal/_assertGuard.js");
596
608
  const _accessExpressionAsString = __webpack_require__("../../../node_modules/.pnpm/typia@10.1.0_typescript@5.9.3/node_modules/typia/lib/internal/_accessExpressionAsString.js");
597
609
  const validateConfig = (()=>{
598
- const _io0 = (input, _exceptionable = true)=>(void 0 === input.compat || "object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) && _io1(input.compat, _exceptionable)) && (void 0 === input.customCSSInheritanceList || Array.isArray(input.customCSSInheritanceList) && input.customCSSInheritanceList.every((elem, _index1)=>"string" == typeof elem)) && (void 0 === input.debugInfoOutside || "boolean" == typeof input.debugInfoOutside) && (void 0 === input.defaultDisplayLinear || "boolean" == typeof input.defaultDisplayLinear) && (void 0 === input.enableAccessibilityElement || "boolean" == typeof input.enableAccessibilityElement) && (void 0 === input.enableCSSInheritance || "boolean" == typeof input.enableCSSInheritance) && (void 0 === input.enableCSSInvalidation || "boolean" == typeof input.enableCSSInvalidation) && (void 0 === input.enableCSSSelector || "boolean" == typeof input.enableCSSSelector) && (void 0 === input.enableNewGesture || "boolean" == typeof input.enableNewGesture) && (void 0 === input.enableRemoveCSSScope || "boolean" == typeof input.enableRemoveCSSScope) && (void 0 === input.firstScreenSyncTiming || "immediately" === input.firstScreenSyncTiming || "jsReady" === input.firstScreenSyncTiming) && (void 0 === input.enableSSR || "boolean" == typeof input.enableSSR) && (void 0 === input.removeDescendantSelectorScope || "boolean" == typeof input.removeDescendantSelectorScope) && (void 0 === input.shake || "object" == typeof input.shake && null !== input.shake && false === Array.isArray(input.shake) && _io4(input.shake, _exceptionable)) && (void 0 === input.defineDCE || "object" == typeof input.defineDCE && null !== input.defineDCE && false === Array.isArray(input.defineDCE) && _io5(input.defineDCE, _exceptionable)) && (void 0 === input.engineVersion || "string" == typeof input.engineVersion) && (void 0 === input.targetSdkVersion || "string" == typeof input.targetSdkVersion) && (void 0 === input.globalPropsMode || "reactive" === input.globalPropsMode || "event" === input.globalPropsMode) && null !== input.extractStr && (void 0 === input.extractStr || "boolean" == typeof input.extractStr || "object" == typeof input.extractStr && null !== input.extractStr && false === Array.isArray(input.extractStr) && _io7(input.extractStr, _exceptionable)) && (void 0 === input.experimental_isLazyBundle || "boolean" == typeof input.experimental_isLazyBundle) && null !== input.optimizeBundleSize && (void 0 === input.optimizeBundleSize || "boolean" == typeof input.optimizeBundleSize || "object" == typeof input.optimizeBundleSize && null !== input.optimizeBundleSize && false === Array.isArray(input.optimizeBundleSize) && _io8(input.optimizeBundleSize, _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
610
+ const _io0 = (input, _exceptionable = true)=>(void 0 === input.enableUiSourceMap || "boolean" == typeof input.enableUiSourceMap) && (void 0 === input.compat || "object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) && _io1(input.compat, _exceptionable)) && (void 0 === input.customCSSInheritanceList || Array.isArray(input.customCSSInheritanceList) && input.customCSSInheritanceList.every((elem, _index1)=>"string" == typeof elem)) && (void 0 === input.debugInfoOutside || "boolean" == typeof input.debugInfoOutside) && (void 0 === input.defaultDisplayLinear || "boolean" == typeof input.defaultDisplayLinear) && (void 0 === input.enableAccessibilityElement || "boolean" == typeof input.enableAccessibilityElement) && (void 0 === input.enableCSSInheritance || "boolean" == typeof input.enableCSSInheritance) && (void 0 === input.enableCSSInvalidation || "boolean" == typeof input.enableCSSInvalidation) && (void 0 === input.enableCSSSelector || "boolean" == typeof input.enableCSSSelector) && (void 0 === input.enableNewGesture || "boolean" == typeof input.enableNewGesture) && (void 0 === input.enableRemoveCSSScope || "boolean" == typeof input.enableRemoveCSSScope) && (void 0 === input.firstScreenSyncTiming || "immediately" === input.firstScreenSyncTiming || "jsReady" === input.firstScreenSyncTiming) && (void 0 === input.enableSSR || "boolean" == typeof input.enableSSR) && (void 0 === input.removeDescendantSelectorScope || "boolean" == typeof input.removeDescendantSelectorScope) && (void 0 === input.shake || "object" == typeof input.shake && null !== input.shake && false === Array.isArray(input.shake) && _io4(input.shake, _exceptionable)) && (void 0 === input.defineDCE || "object" == typeof input.defineDCE && null !== input.defineDCE && false === Array.isArray(input.defineDCE) && _io5(input.defineDCE, _exceptionable)) && (void 0 === input.engineVersion || "string" == typeof input.engineVersion) && (void 0 === input.targetSdkVersion || "string" == typeof input.targetSdkVersion) && (void 0 === input.globalPropsMode || "reactive" === input.globalPropsMode || "event" === input.globalPropsMode) && null !== input.extractStr && (void 0 === input.extractStr || "boolean" == typeof input.extractStr || "object" == typeof input.extractStr && null !== input.extractStr && false === Array.isArray(input.extractStr) && _io7(input.extractStr, _exceptionable)) && (void 0 === input.experimental_isLazyBundle || "boolean" == typeof input.experimental_isLazyBundle) && null !== input.optimizeBundleSize && (void 0 === input.optimizeBundleSize || "boolean" == typeof input.optimizeBundleSize || "object" == typeof input.optimizeBundleSize && null !== input.optimizeBundleSize && false === Array.isArray(input.optimizeBundleSize) && _io8(input.optimizeBundleSize, _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
599
611
  if ([
612
+ "enableUiSourceMap",
600
613
  "compat",
601
614
  "customCSSInheritanceList",
602
615
  "debugInfoOutside",
@@ -697,7 +710,12 @@ const validateConfig = (()=>{
697
710
  if (void 0 === value) return true;
698
711
  return false;
699
712
  }));
700
- const _ao0 = (input, _path, _exceptionable = true)=>(void 0 === input.compat || ("object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) || _assertGuard._assertGuard(_exceptionable, {
713
+ const _ao0 = (input, _path, _exceptionable = true)=>(void 0 === input.enableUiSourceMap || "boolean" == typeof input.enableUiSourceMap || _assertGuard._assertGuard(_exceptionable, {
714
+ method: "typia.createAssertEquals",
715
+ path: _path + ".enableUiSourceMap",
716
+ expected: "(boolean | undefined)",
717
+ value: input.enableUiSourceMap
718
+ }, _errorFactory)) && (void 0 === input.compat || ("object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) || _assertGuard._assertGuard(_exceptionable, {
701
719
  method: "typia.createAssertEquals",
702
720
  path: _path + ".compat",
703
721
  expected: "(Partial<CompatVisitorConfig> & { disableCreateSelectorQueryIncompatibleWarning?: boolean; } | undefined)",
@@ -849,6 +867,7 @@ const validateConfig = (()=>{
849
867
  value: input.optimizeBundleSize
850
868
  }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
851
869
  if ([
870
+ "enableUiSourceMap",
852
871
  "compat",
853
872
  "customCSSInheritanceList",
854
873
  "debugInfoOutside",
@@ -1247,7 +1266,8 @@ function pluginReactLynx(userOptions) {
1247
1266
  extractStr: false,
1248
1267
  globalPropsMode: 'reactive',
1249
1268
  experimental_isLazyBundle: false,
1250
- optimizeBundleSize: false
1269
+ optimizeBundleSize: false,
1270
+ enableUiSourceMap: false
1251
1271
  };
1252
1272
  const resolvedOptions = Object.assign(defaultOptions, userOptions, {
1253
1273
  targetSdkVersion: engineVersion,
@@ -1266,17 +1286,19 @@ function pluginReactLynx(userOptions) {
1266
1286
  ],
1267
1287
  setup (api) {
1268
1288
  const isRslib = 'rslib' === api.context.callerName;
1289
+ const isRstest = 'rstest' === api.context.callerName;
1269
1290
  const exposedConfig = api.useExposed(Symbol.for('lynx.config'));
1270
1291
  if (exposedConfig) Object.keys(defaultOptions).forEach((key)=>{
1271
1292
  if (Object.hasOwn(exposedConfig.config, key)) Object.assign(resolvedOptions, {
1272
1293
  [key]: exposedConfig.config[key]
1273
1294
  });
1274
1295
  });
1275
- applyCSS(api, resolvedOptions);
1296
+ if (!isRstest) applyCSS(api, resolvedOptions);
1276
1297
  applyEntry(api, resolvedOptions);
1277
1298
  applyBackgroundOnly(api);
1278
1299
  applyGenerator(api, resolvedOptions);
1279
- applyLoaders(api, resolvedOptions);
1300
+ if (isRstest) applyTestingLoaders(api, resolvedOptions);
1301
+ else applyLoaders(api, resolvedOptions);
1280
1302
  applyRefresh(api);
1281
1303
  applySplitChunksRule(api);
1282
1304
  applySWC(api);
package/dist/index.d.ts CHANGED
@@ -440,6 +440,12 @@ export declare function pluginReactLynx(userOptions?: PluginReactLynxOptions): R
440
440
  * @public
441
441
  */
442
442
  export declare interface PluginReactLynxOptions {
443
+ /**
444
+ * Enable UI source map generation and debug-metadata asset emission.
445
+ *
446
+ * @defaultValue `false`
447
+ */
448
+ enableUiSourceMap?: boolean;
443
449
  /**
444
450
  * The `compat` option controls compatibilities with ReactLynx2.0.
445
451
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-rsbuild-plugin",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "A rsbuild plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "rsbuild",
@@ -32,12 +32,13 @@
32
32
  "README.md"
33
33
  ],
34
34
  "dependencies": {
35
- "@lynx-js/css-extract-webpack-plugin": "0.7.0",
36
- "@lynx-js/react-alias-rsbuild-plugin": "0.15.0",
35
+ "tiny-invariant": "^1.3.3",
36
+ "@lynx-js/css-extract-webpack-plugin": "0.7.1",
37
+ "@lynx-js/react-alias-rsbuild-plugin": "0.16.1",
37
38
  "@lynx-js/react-refresh-webpack-plugin": "0.3.5",
38
- "@lynx-js/react-webpack-plugin": "0.9.0",
39
+ "@lynx-js/react-webpack-plugin": "0.9.2",
39
40
  "@lynx-js/runtime-wrapper-webpack-plugin": "0.1.3",
40
- "@lynx-js/template-webpack-plugin": "0.10.8",
41
+ "@lynx-js/template-webpack-plugin": "0.11.0",
41
42
  "@lynx-js/use-sync-external-store": "1.5.0",
42
43
  "background-only": "^0.0.1"
43
44
  },
@@ -55,13 +56,13 @@
55
56
  "typia": "10.1.0",
56
57
  "typia-rspack-plugin": "2.2.2",
57
58
  "@lynx-js/config-rsbuild-plugin": "0.0.2",
58
- "@lynx-js/react": "0.118.0",
59
+ "@lynx-js/react": "0.120.0",
59
60
  "@lynx-js/react-transform": "0.2.0",
60
- "@lynx-js/rspeedy": "0.14.1",
61
+ "@lynx-js/rspeedy": "0.14.3",
61
62
  "@lynx-js/vitest-setup": "0.0.0"
62
63
  },
63
64
  "peerDependencies": {
64
- "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0 || ^0.113.0 || ^0.114.0 || ^0.115.0 || ^0.116.0 || ^0.117.0 || ^0.118.0"
65
+ "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0 || ^0.113.0 || ^0.114.0 || ^0.115.0 || ^0.116.0 || ^0.117.0 || ^0.118.0 || ^0.119.0 || ^0.120.0"
65
66
  },
66
67
  "peerDependenciesMeta": {
67
68
  "@lynx-js/react": {