@lynx-js/react-rsbuild-plugin-canary 0.13.0 → 0.14.0-canary-20260324-e3e63dec
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 +55 -47
- package/dist/208.js +91 -4
- package/dist/index.d.ts +14 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @lynx-js/react-rsbuild-plugin
|
|
2
2
|
|
|
3
|
+
## 0.14.0-canary-20260324045843-e3e63dec57eec2ba04744619714bf1845f857c91
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: support `optimizeBundleSize` option to remove unused code for main-thread and background. ([#2336](https://github.com/lynx-family/lynx-stack/pull/2336))
|
|
8
|
+
- If `optimizeBundleSize` is `true` or `optimizeBundleSize.background` is `true`, `lynx.registerDataProcessors` calls will be marked as pure for the background thread output.
|
|
9
|
+
- If `optimizeBundleSize` is `true` or `optimizeBundleSize.mainThread` is `true`, `NativeModules.call` and `lynx.getJSModule` calls will be marked as pure for the main-thread output.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies []:
|
|
14
|
+
- @lynx-js/react-alias-rsbuild-plugin@0.14.0-canary-20260324045843-e3e63dec57eec2ba04744619714bf1845f857c91
|
|
15
|
+
|
|
3
16
|
## 0.13.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -11,7 +24,6 @@
|
|
|
11
24
|
Upgrade preact from [f7693b72](https://github.com/preactjs/preact/commit/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0) to [55254ef7](https://github.com/preactjs/preact/commit/55254ef7021e563cc1a86fb816058964a1b6a29a), see diffs at [f7693b72...55254ef7](https://github.com/preactjs/preact/compare/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0...preactjs:preact:55254ef7021e563cc1a86fb816058964a1b6a29a?expand=1).
|
|
12
25
|
|
|
13
26
|
- feat: add `globalPropsMode` option to `PluginReactLynxOptions` ([#2346](https://github.com/lynx-family/lynx-stack/pull/2346))
|
|
14
|
-
|
|
15
27
|
- When configured to `"event"`, `updateGlobalProps` will only trigger a global event and skip the `runWithForce` flow.
|
|
16
28
|
- Defaults to `"reactive"`, which means `updateGlobalProps` will trigger re-render automatically.
|
|
17
29
|
|
|
@@ -180,8 +192,8 @@
|
|
|
180
192
|
With this change you can setup [React Compiler](https://react.dev/learn/react-compiler) for ReactLynx by `pluginBabel`:
|
|
181
193
|
|
|
182
194
|
```js
|
|
183
|
-
import { defineConfig } from
|
|
184
|
-
import { pluginBabel } from
|
|
195
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
196
|
+
import { pluginBabel } from "@rsbuild/plugin-babel";
|
|
185
197
|
|
|
186
198
|
export default defineConfig({
|
|
187
199
|
plugins: [
|
|
@@ -189,17 +201,17 @@
|
|
|
189
201
|
include: /\.(?:jsx|tsx)$/,
|
|
190
202
|
babelLoaderOptions(opts) {
|
|
191
203
|
opts.plugins?.unshift([
|
|
192
|
-
|
|
204
|
+
"babel-plugin-react-compiler",
|
|
193
205
|
// See https://react.dev/reference/react-compiler/configuration for config
|
|
194
206
|
{
|
|
195
207
|
// ReactLynx only supports target to version 17
|
|
196
|
-
target:
|
|
208
|
+
target: "17",
|
|
197
209
|
},
|
|
198
|
-
])
|
|
210
|
+
]);
|
|
199
211
|
},
|
|
200
212
|
}),
|
|
201
213
|
],
|
|
202
|
-
})
|
|
214
|
+
});
|
|
203
215
|
```
|
|
204
216
|
|
|
205
217
|
- Updated dependencies [[`e7d186a`](https://github.com/lynx-family/lynx-stack/commit/e7d186a6fcf08fecf18b5ab82b004b955bb1a2b3), [`0d7a4c3`](https://github.com/lynx-family/lynx-stack/commit/0d7a4c3d49d63e30d5f05c372ef99ee5cf2fcadd)]:
|
|
@@ -402,28 +414,28 @@
|
|
|
402
414
|
|
|
403
415
|
```ts
|
|
404
416
|
type InlineChunkTestFunction = (params: {
|
|
405
|
-
size: number
|
|
406
|
-
name: string
|
|
407
|
-
}) => boolean
|
|
417
|
+
size: number;
|
|
418
|
+
name: string;
|
|
419
|
+
}) => boolean;
|
|
408
420
|
|
|
409
|
-
type InlineChunkTest = RegExp | InlineChunkTestFunction
|
|
421
|
+
type InlineChunkTest = RegExp | InlineChunkTestFunction;
|
|
410
422
|
|
|
411
423
|
type InlineChunkConfig =
|
|
412
424
|
| boolean
|
|
413
425
|
| InlineChunkTest
|
|
414
|
-
| { enable?: boolean |
|
|
426
|
+
| { enable?: boolean | "auto"; test: InlineChunkTest };
|
|
415
427
|
```
|
|
416
428
|
|
|
417
429
|
```ts
|
|
418
|
-
import { defineConfig } from
|
|
430
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
419
431
|
|
|
420
432
|
export default defineConfig({
|
|
421
433
|
output: {
|
|
422
434
|
inlineScripts: ({ name, size }) => {
|
|
423
|
-
return name.includes(
|
|
435
|
+
return name.includes("foo") && size < 1000;
|
|
424
436
|
},
|
|
425
437
|
},
|
|
426
|
-
})
|
|
438
|
+
});
|
|
427
439
|
```
|
|
428
440
|
|
|
429
441
|
- Updated dependencies [[`51cb73d`](https://github.com/lynx-family/lynx-stack/commit/51cb73dd0b77d35540644cdd2e6c37db856f0e8a), [`69fb042`](https://github.com/lynx-family/lynx-stack/commit/69fb0420e297abf768c889769c95a207c480b3c7), [`a7e8b5b`](https://github.com/lynx-family/lynx-stack/commit/a7e8b5bbbab0490e7cf6f47581130e7b32739abb)]:
|
|
@@ -503,13 +515,13 @@
|
|
|
503
515
|
example:
|
|
504
516
|
|
|
505
517
|
```js
|
|
506
|
-
import { defineConfig } from
|
|
518
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
507
519
|
|
|
508
520
|
export default defineConfig({
|
|
509
521
|
output: {
|
|
510
522
|
inlineScripts: false,
|
|
511
523
|
},
|
|
512
|
-
})
|
|
524
|
+
});
|
|
513
525
|
```
|
|
514
526
|
|
|
515
527
|
- Support `@lynx-js/react` v0.109.0. ([#840](https://github.com/lynx-family/lynx-stack/pull/840))
|
|
@@ -567,7 +579,6 @@
|
|
|
567
579
|
- Refactor: Replace built-in `background-only` implementation with npm package ([#602](https://github.com/lynx-family/lynx-stack/pull/602))
|
|
568
580
|
|
|
569
581
|
Previously we maintained custom files:
|
|
570
|
-
|
|
571
582
|
- `empty.ts` for background thread
|
|
572
583
|
- `error.ts` for main thread validation
|
|
573
584
|
|
|
@@ -596,7 +607,7 @@
|
|
|
596
607
|
Now you can override configuration like `useDefineForClassFields` using `tools.swc`.
|
|
597
608
|
|
|
598
609
|
```js
|
|
599
|
-
import { defineConfig } from
|
|
610
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
600
611
|
|
|
601
612
|
export default defineConfig({
|
|
602
613
|
tools: {
|
|
@@ -608,7 +619,7 @@
|
|
|
608
619
|
},
|
|
609
620
|
},
|
|
610
621
|
},
|
|
611
|
-
})
|
|
622
|
+
});
|
|
612
623
|
```
|
|
613
624
|
|
|
614
625
|
- Updated dependencies [[`f1ca29b`](https://github.com/lynx-family/lynx-stack/commit/f1ca29bd766377dd46583f15e1e75bca447699cd)]:
|
|
@@ -784,7 +795,7 @@
|
|
|
784
795
|
You may turn it off using `output.minify.css: false`:
|
|
785
796
|
|
|
786
797
|
```js
|
|
787
|
-
import { defineConfig } from
|
|
798
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
788
799
|
|
|
789
800
|
export default defineConfig({
|
|
790
801
|
output: {
|
|
@@ -792,18 +803,18 @@
|
|
|
792
803
|
css: false,
|
|
793
804
|
},
|
|
794
805
|
},
|
|
795
|
-
})
|
|
806
|
+
});
|
|
796
807
|
```
|
|
797
808
|
|
|
798
809
|
Or you may use [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) to use `cssnano` as CSS minimizer.
|
|
799
810
|
|
|
800
811
|
```js
|
|
801
|
-
import { defineConfig } from
|
|
802
|
-
import { pluginCssMinimizer } from
|
|
812
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
813
|
+
import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
|
|
803
814
|
|
|
804
815
|
export default defineConfig({
|
|
805
816
|
plugins: [pluginCssMinimizer()],
|
|
806
|
-
})
|
|
817
|
+
});
|
|
807
818
|
```
|
|
808
819
|
|
|
809
820
|
### Patch Changes
|
|
@@ -857,7 +868,6 @@
|
|
|
857
868
|
|
|
858
869
|
- 7b84edf: feat(web): introduce new output chunk format
|
|
859
870
|
- 39efd7c: Change `enableRemoveCSSScope` defaults from `undefined` to `true`, now `enableRemoveCSSScope` can be:
|
|
860
|
-
|
|
861
871
|
- `true` (by default): All CSS files are treated as global CSS.
|
|
862
872
|
- `false`: All CSS files are treated as scoped CSS, and only take effect in the component that explicitly imports it.
|
|
863
873
|
- `undefined`: Only use scoped CSS for CSS Modules, and treat other CSS files as global CSS. Scoped CSS is faster than global CSS, thus you can use CSS Modules to speedy up your CSS if there are performance issues.
|
|
@@ -883,18 +893,18 @@
|
|
|
883
893
|
- e8039f2: Add `defineDCE` in plugin options. Often used to define custom macros.
|
|
884
894
|
|
|
885
895
|
```js
|
|
886
|
-
import { pluginReactLynx } from
|
|
887
|
-
import { defineConfig } from
|
|
896
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
897
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
888
898
|
|
|
889
899
|
export default defineConfig({
|
|
890
900
|
plugins: [
|
|
891
901
|
pluginReactLynx({
|
|
892
902
|
defineDCE: {
|
|
893
|
-
__SOME_FALSE_DEFINE__:
|
|
903
|
+
__SOME_FALSE_DEFINE__: "false",
|
|
894
904
|
},
|
|
895
905
|
}),
|
|
896
906
|
],
|
|
897
|
-
})
|
|
907
|
+
});
|
|
898
908
|
```
|
|
899
909
|
|
|
900
910
|
Different from `define` provided by bundlers like webpack, `defineDCE` works at transform time and a extra DCE (Dead Code Elimination) pass will be performed.
|
|
@@ -902,20 +912,20 @@
|
|
|
902
912
|
For example, `import` initialized by dead code will be removed:
|
|
903
913
|
|
|
904
914
|
```js
|
|
905
|
-
import { foo } from
|
|
915
|
+
import { foo } from "bar";
|
|
906
916
|
|
|
907
917
|
if (__SOME_FALSE_DEFINE__) {
|
|
908
|
-
foo()
|
|
909
|
-
console.log(
|
|
918
|
+
foo();
|
|
919
|
+
console.log("dead code");
|
|
910
920
|
} else {
|
|
911
|
-
console.log(
|
|
921
|
+
console.log("reachable code");
|
|
912
922
|
}
|
|
913
923
|
```
|
|
914
924
|
|
|
915
925
|
will be transformed to:
|
|
916
926
|
|
|
917
927
|
```js
|
|
918
|
-
console.log(
|
|
928
|
+
console.log("reachable code");
|
|
919
929
|
```
|
|
920
930
|
|
|
921
931
|
- Updated dependencies [8dd6cca]
|
|
@@ -934,7 +944,6 @@
|
|
|
934
944
|
- 958efda: feat(web): bundle background.js into main-thread.js for web
|
|
935
945
|
|
|
936
946
|
To enable this feature:
|
|
937
|
-
|
|
938
947
|
1. set the performance.chunkSplit.strategy to `all-in-one`
|
|
939
948
|
2. use the `mode:'production'` to build
|
|
940
949
|
|
|
@@ -958,18 +967,18 @@
|
|
|
958
967
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
959
968
|
|
|
960
969
|
```js
|
|
961
|
-
import { pluginReactLynx } from
|
|
962
|
-
import { defineConfig } from
|
|
970
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
971
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
963
972
|
|
|
964
973
|
export default defineConfig({
|
|
965
974
|
plugins: [
|
|
966
975
|
pluginReactLynx({
|
|
967
976
|
compat: {
|
|
968
|
-
removeComponentAttrRegex:
|
|
977
|
+
removeComponentAttrRegex: "YOUR REGEX",
|
|
969
978
|
},
|
|
970
979
|
}),
|
|
971
980
|
],
|
|
972
|
-
})
|
|
981
|
+
});
|
|
973
982
|
```
|
|
974
983
|
|
|
975
984
|
NOTE: This feature is deprecated and will be removed in the future. Use CodeMod instead.
|
|
@@ -981,18 +990,17 @@
|
|
|
981
990
|
|
|
982
991
|
- 36f8e4c: Add `enableAccessibilityElement`.
|
|
983
992
|
- b37e3d9: Enforced build-time errors for importing `background-only` modules in the `main-thread`.
|
|
984
|
-
|
|
985
993
|
- use `import 'background-only'` to mark a module as restricted to the background environment. Any attempt to import such a module in the main thread will result in a build-time error.
|
|
986
994
|
|
|
987
995
|
For example:
|
|
988
996
|
|
|
989
997
|
```javascript
|
|
990
998
|
// bar.ts
|
|
991
|
-
import
|
|
999
|
+
import "background-only";
|
|
992
1000
|
|
|
993
1001
|
export const bar = () => {
|
|
994
|
-
return
|
|
995
|
-
}
|
|
1002
|
+
return "bar";
|
|
1003
|
+
};
|
|
996
1004
|
```
|
|
997
1005
|
|
|
998
1006
|
If `bar` is called in `main-thread`, build time error will be triggered.
|
|
@@ -1001,15 +1009,15 @@
|
|
|
1001
1009
|
|
|
1002
1010
|
```tsx
|
|
1003
1011
|
// App.tsx
|
|
1004
|
-
import { bar } from
|
|
1012
|
+
import { bar } from "./bar.js";
|
|
1005
1013
|
|
|
1006
1014
|
function App() {
|
|
1007
|
-
bar()
|
|
1015
|
+
bar();
|
|
1008
1016
|
return (
|
|
1009
1017
|
<view>
|
|
1010
1018
|
<text>Hello, Lynx x rspeedy</text>
|
|
1011
1019
|
</view>
|
|
1012
|
-
)
|
|
1020
|
+
);
|
|
1013
1021
|
}
|
|
1014
1022
|
```
|
|
1015
1023
|
|
package/dist/208.js
CHANGED
|
@@ -443,6 +443,41 @@ function applyNodeEnv(api) {
|
|
|
443
443
|
}
|
|
444
444
|
}));
|
|
445
445
|
}
|
|
446
|
+
function applyOptimizeBundleSize(api, options) {
|
|
447
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
448
|
+
const optimizeBundleSize = options.optimizeBundleSize;
|
|
449
|
+
const optimizeBackground = 'boolean' == typeof optimizeBundleSize ? optimizeBundleSize : optimizeBundleSize?.background;
|
|
450
|
+
const optimizeMainThread = 'boolean' == typeof optimizeBundleSize ? optimizeBundleSize : optimizeBundleSize?.mainThread;
|
|
451
|
+
if (optimizeBackground || optimizeMainThread) {
|
|
452
|
+
const minifyConfig = {};
|
|
453
|
+
if (optimizeBackground) minifyConfig['backgroundOptions'] = {
|
|
454
|
+
minimizerOptions: {
|
|
455
|
+
compress: {
|
|
456
|
+
pure_funcs: [
|
|
457
|
+
'lynx.registerDataProcessors'
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
if (optimizeMainThread) minifyConfig['mainThreadOptions'] = {
|
|
463
|
+
minimizerOptions: {
|
|
464
|
+
compress: {
|
|
465
|
+
pure_funcs: [
|
|
466
|
+
'NativeModules.call',
|
|
467
|
+
'lynx.getJSModule'
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
return mergeRsbuildConfig(config, {
|
|
473
|
+
output: {
|
|
474
|
+
minify: minifyConfig
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
return config;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
446
481
|
const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh';
|
|
447
482
|
function applyRefresh(api) {
|
|
448
483
|
api.modifyWebpackChain(async (chain, { CHAIN_ID, isProd })=>{
|
|
@@ -563,7 +598,7 @@ function applyUseSyncExternalStore(api) {
|
|
|
563
598
|
const _assertGuard = __webpack_require__("../../../node_modules/.pnpm/typia@10.1.0_typescript@5.9.3/node_modules/typia/lib/internal/_assertGuard.js");
|
|
564
599
|
const _accessExpressionAsString = __webpack_require__("../../../node_modules/.pnpm/typia@10.1.0_typescript@5.9.3/node_modules/typia/lib/internal/_accessExpressionAsString.js");
|
|
565
600
|
const validateConfig = (()=>{
|
|
566
|
-
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) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
|
|
601
|
+
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)=>{
|
|
567
602
|
if ([
|
|
568
603
|
"compat",
|
|
569
604
|
"customCSSInheritanceList",
|
|
@@ -584,7 +619,8 @@ const validateConfig = (()=>{
|
|
|
584
619
|
"targetSdkVersion",
|
|
585
620
|
"globalPropsMode",
|
|
586
621
|
"extractStr",
|
|
587
|
-
"experimental_isLazyBundle"
|
|
622
|
+
"experimental_isLazyBundle",
|
|
623
|
+
"optimizeBundleSize"
|
|
588
624
|
].some((prop)=>key === prop)) return true;
|
|
589
625
|
const value = input[key];
|
|
590
626
|
if (void 0 === value) return true;
|
|
@@ -654,6 +690,15 @@ const validateConfig = (()=>{
|
|
|
654
690
|
if (void 0 === value) return true;
|
|
655
691
|
return false;
|
|
656
692
|
}));
|
|
693
|
+
const _io8 = (input, _exceptionable = true)=>(void 0 === input.mainThread || "boolean" == typeof input.mainThread) && (void 0 === input.background || "boolean" == typeof input.background) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
|
|
694
|
+
if ([
|
|
695
|
+
"mainThread",
|
|
696
|
+
"background"
|
|
697
|
+
].some((prop)=>key === prop)) return true;
|
|
698
|
+
const value = input[key];
|
|
699
|
+
if (void 0 === value) return true;
|
|
700
|
+
return false;
|
|
701
|
+
}));
|
|
657
702
|
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, {
|
|
658
703
|
method: "typia.createAssertEquals",
|
|
659
704
|
path: _path + ".compat",
|
|
@@ -789,6 +834,21 @@ const validateConfig = (()=>{
|
|
|
789
834
|
path: _path + ".experimental_isLazyBundle",
|
|
790
835
|
expected: "(boolean | undefined)",
|
|
791
836
|
value: input.experimental_isLazyBundle
|
|
837
|
+
}, _errorFactory)) && (null !== input.optimizeBundleSize || _assertGuard._assertGuard(_exceptionable, {
|
|
838
|
+
method: "typia.createAssertEquals",
|
|
839
|
+
path: _path + ".optimizeBundleSize",
|
|
840
|
+
expected: "(__type | boolean | undefined)",
|
|
841
|
+
value: input.optimizeBundleSize
|
|
842
|
+
}, _errorFactory)) && (void 0 === input.optimizeBundleSize || "boolean" == typeof input.optimizeBundleSize || ("object" == typeof input.optimizeBundleSize && null !== input.optimizeBundleSize && false === Array.isArray(input.optimizeBundleSize) || _assertGuard._assertGuard(_exceptionable, {
|
|
843
|
+
method: "typia.createAssertEquals",
|
|
844
|
+
path: _path + ".optimizeBundleSize",
|
|
845
|
+
expected: "(__type | boolean | undefined)",
|
|
846
|
+
value: input.optimizeBundleSize
|
|
847
|
+
}, _errorFactory)) && _ao8(input.optimizeBundleSize, _path + ".optimizeBundleSize", _exceptionable) || _assertGuard._assertGuard(_exceptionable, {
|
|
848
|
+
method: "typia.createAssertEquals",
|
|
849
|
+
path: _path + ".optimizeBundleSize",
|
|
850
|
+
expected: "(__type | boolean | undefined)",
|
|
851
|
+
value: input.optimizeBundleSize
|
|
792
852
|
}, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
|
|
793
853
|
if ([
|
|
794
854
|
"compat",
|
|
@@ -810,7 +870,8 @@ const validateConfig = (()=>{
|
|
|
810
870
|
"targetSdkVersion",
|
|
811
871
|
"globalPropsMode",
|
|
812
872
|
"extractStr",
|
|
813
|
-
"experimental_isLazyBundle"
|
|
873
|
+
"experimental_isLazyBundle",
|
|
874
|
+
"optimizeBundleSize"
|
|
814
875
|
].some((prop)=>key === prop)) return true;
|
|
815
876
|
const value = input[key];
|
|
816
877
|
if (void 0 === value) return true;
|
|
@@ -1090,6 +1151,30 @@ const validateConfig = (()=>{
|
|
|
1090
1151
|
value: value
|
|
1091
1152
|
}, _errorFactory);
|
|
1092
1153
|
}));
|
|
1154
|
+
const _ao8 = (input, _path, _exceptionable = true)=>(void 0 === input.mainThread || "boolean" == typeof input.mainThread || _assertGuard._assertGuard(_exceptionable, {
|
|
1155
|
+
method: "typia.createAssertEquals",
|
|
1156
|
+
path: _path + ".mainThread",
|
|
1157
|
+
expected: "(boolean | undefined)",
|
|
1158
|
+
value: input.mainThread
|
|
1159
|
+
}, _errorFactory)) && (void 0 === input.background || "boolean" == typeof input.background || _assertGuard._assertGuard(_exceptionable, {
|
|
1160
|
+
method: "typia.createAssertEquals",
|
|
1161
|
+
path: _path + ".background",
|
|
1162
|
+
expected: "(boolean | undefined)",
|
|
1163
|
+
value: input.background
|
|
1164
|
+
}, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
|
|
1165
|
+
if ([
|
|
1166
|
+
"mainThread",
|
|
1167
|
+
"background"
|
|
1168
|
+
].some((prop)=>key === prop)) return true;
|
|
1169
|
+
const value = input[key];
|
|
1170
|
+
if (void 0 === value) return true;
|
|
1171
|
+
return _assertGuard._assertGuard(_exceptionable, {
|
|
1172
|
+
method: "typia.createAssertEquals",
|
|
1173
|
+
path: _path + _accessExpressionAsString._accessExpressionAsString(key),
|
|
1174
|
+
expected: "undefined",
|
|
1175
|
+
value: value
|
|
1176
|
+
}, _errorFactory);
|
|
1177
|
+
}));
|
|
1093
1178
|
const __is = (input, _exceptionable = true)=>void 0 === input || "object" == typeof input && null !== input && false === Array.isArray(input) && _io0(input, true);
|
|
1094
1179
|
let _errorFactory;
|
|
1095
1180
|
return (input, errorFactory = ({ path, expected, value })=>{
|
|
@@ -1147,7 +1232,8 @@ function pluginReactLynx(userOptions) {
|
|
|
1147
1232
|
engineVersion: '',
|
|
1148
1233
|
extractStr: false,
|
|
1149
1234
|
globalPropsMode: 'reactive',
|
|
1150
|
-
experimental_isLazyBundle: false
|
|
1235
|
+
experimental_isLazyBundle: false,
|
|
1236
|
+
optimizeBundleSize: false
|
|
1151
1237
|
};
|
|
1152
1238
|
const resolvedOptions = Object.assign(defaultOptions, userOptions, {
|
|
1153
1239
|
targetSdkVersion: engineVersion,
|
|
@@ -1209,6 +1295,7 @@ function pluginReactLynx(userOptions) {
|
|
|
1209
1295
|
}, config);
|
|
1210
1296
|
return config;
|
|
1211
1297
|
});
|
|
1298
|
+
if (resolvedOptions.optimizeBundleSize) applyOptimizeBundleSize(api, resolvedOptions);
|
|
1212
1299
|
if (resolvedOptions.experimental_isLazyBundle) applyLazy(api);
|
|
1213
1300
|
api.expose(Symbol.for('LAYERS'), LAYERS);
|
|
1214
1301
|
api.expose(Symbol.for('LynxTemplatePlugin'), {
|
package/dist/index.d.ts
CHANGED
|
@@ -640,6 +640,7 @@ export declare interface PluginReactLynxOptions {
|
|
|
640
640
|
* `'event'`: `UpdateGlobalProps` will trigger global event and users need to trigger update in the event handler.
|
|
641
641
|
*
|
|
642
642
|
* @defaultValue `'reactive'`
|
|
643
|
+
* @public
|
|
643
644
|
*/
|
|
644
645
|
globalPropsMode?: 'reactive' | 'event';
|
|
645
646
|
/**
|
|
@@ -655,6 +656,19 @@ export declare interface PluginReactLynxOptions {
|
|
|
655
656
|
* @alpha
|
|
656
657
|
*/
|
|
657
658
|
experimental_isLazyBundle?: boolean;
|
|
659
|
+
/**
|
|
660
|
+
* Optimize bundle size by removing unused code by Minify.mainThreadOptions and Minify.backgroundOptions.
|
|
661
|
+
*
|
|
662
|
+
* When optimizeBundleSize or optimizeBundleSize.mainThread is true, main-thread code will be optimized.
|
|
663
|
+
* When optimizeBundleSize or optimizeBundleSize.background is true, background code will be optimized.
|
|
664
|
+
*
|
|
665
|
+
* @defaultValue `false`
|
|
666
|
+
* @public
|
|
667
|
+
*/
|
|
668
|
+
optimizeBundleSize?: boolean | {
|
|
669
|
+
mainThread?: boolean;
|
|
670
|
+
background?: boolean;
|
|
671
|
+
};
|
|
658
672
|
}
|
|
659
673
|
|
|
660
674
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-rsbuild-plugin-canary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-canary-20260324-e3e63dec",
|
|
4
4
|
"description": "A rsbuild plugin for ReactLynx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rsbuild",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@lynx-js/css-extract-webpack-plugin": "npm:@lynx-js/css-extract-webpack-plugin-canary@0.7.0",
|
|
36
|
-
"@lynx-js/react-alias-rsbuild-plugin": "npm:@lynx-js/react-alias-rsbuild-plugin-canary@0.
|
|
36
|
+
"@lynx-js/react-alias-rsbuild-plugin": "npm:@lynx-js/react-alias-rsbuild-plugin-canary@0.14.0-canary-20260324-e3e63dec",
|
|
37
37
|
"@lynx-js/react-refresh-webpack-plugin": "npm:@lynx-js/react-refresh-webpack-plugin-canary@0.3.5",
|
|
38
38
|
"@lynx-js/react-webpack-plugin": "npm:@lynx-js/react-webpack-plugin-canary@0.8.0",
|
|
39
39
|
"@lynx-js/runtime-wrapper-webpack-plugin": "npm:@lynx-js/runtime-wrapper-webpack-plugin-canary@0.1.3",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"typia-rspack-plugin": "2.2.2",
|
|
57
57
|
"@lynx-js/config-rsbuild-plugin": "npm:@lynx-js/config-rsbuild-plugin-canary@0.0.1",
|
|
58
58
|
"@lynx-js/react": "npm:@lynx-js/react-canary@0.117.0",
|
|
59
|
+
"@lynx-js/vitest-setup": "0.0.0",
|
|
59
60
|
"@lynx-js/react-transform": "0.2.0",
|
|
60
|
-
"@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.
|
|
61
|
-
"@lynx-js/vitest-setup": "0.0.0"
|
|
61
|
+
"@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.14.0-canary-20260324-e3e63dec"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@lynx-js/react": "*"
|