@lynx-js/react-rsbuild-plugin-canary 0.11.1 → 0.11.2-canary-20251010-e21c4e23
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 +49 -36
- package/dist/index.js +18 -8
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @lynx-js/react-rsbuild-plugin
|
|
2
2
|
|
|
3
|
+
## 0.11.2-canary-20251010135203-e21c4e23ca87c0783faaa4cfd2f8dfe6ca6d84eb
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix using wrong version of `@lynx-js/react/refresh`. ([#1756](https://github.com/lynx-family/lynx-stack/pull/1756))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`2da147d`](https://github.com/lynx-family/lynx-stack/commit/2da147d28e1ea3e48eeaba4eac9923e0285300d4)]:
|
|
10
|
+
- @lynx-js/react@0.114.2-canary-20251010135203-e21c4e23ca87c0783faaa4cfd2f8dfe6ca6d84eb
|
|
11
|
+
- @lynx-js/react-alias-rsbuild-plugin@0.11.2-canary-20251010135203-e21c4e23ca87c0783faaa4cfd2f8dfe6ca6d84eb
|
|
12
|
+
- @lynx-js/use-sync-external-store@1.5.0
|
|
13
|
+
- @lynx-js/react-refresh-webpack-plugin@0.3.4
|
|
14
|
+
- @lynx-js/react-webpack-plugin@0.7.1
|
|
15
|
+
|
|
3
16
|
## 0.11.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -172,28 +185,28 @@
|
|
|
172
185
|
|
|
173
186
|
```ts
|
|
174
187
|
type InlineChunkTestFunction = (params: {
|
|
175
|
-
size: number
|
|
176
|
-
name: string
|
|
177
|
-
}) => boolean
|
|
188
|
+
size: number;
|
|
189
|
+
name: string;
|
|
190
|
+
}) => boolean;
|
|
178
191
|
|
|
179
|
-
type InlineChunkTest = RegExp | InlineChunkTestFunction
|
|
192
|
+
type InlineChunkTest = RegExp | InlineChunkTestFunction;
|
|
180
193
|
|
|
181
194
|
type InlineChunkConfig =
|
|
182
195
|
| boolean
|
|
183
196
|
| InlineChunkTest
|
|
184
|
-
| { enable?: boolean |
|
|
197
|
+
| { enable?: boolean | "auto"; test: InlineChunkTest };
|
|
185
198
|
```
|
|
186
199
|
|
|
187
200
|
```ts
|
|
188
|
-
import { defineConfig } from
|
|
201
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
189
202
|
|
|
190
203
|
export default defineConfig({
|
|
191
204
|
output: {
|
|
192
205
|
inlineScripts: ({ name, size }) => {
|
|
193
|
-
return name.includes(
|
|
206
|
+
return name.includes("foo") && size < 1000;
|
|
194
207
|
},
|
|
195
208
|
},
|
|
196
|
-
})
|
|
209
|
+
});
|
|
197
210
|
```
|
|
198
211
|
|
|
199
212
|
- 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)]:
|
|
@@ -273,13 +286,13 @@
|
|
|
273
286
|
example:
|
|
274
287
|
|
|
275
288
|
```js
|
|
276
|
-
import { defineConfig } from
|
|
289
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
277
290
|
|
|
278
291
|
export default defineConfig({
|
|
279
292
|
output: {
|
|
280
293
|
inlineScripts: false,
|
|
281
294
|
},
|
|
282
|
-
})
|
|
295
|
+
});
|
|
283
296
|
```
|
|
284
297
|
|
|
285
298
|
- Support `@lynx-js/react` v0.109.0. ([#840](https://github.com/lynx-family/lynx-stack/pull/840))
|
|
@@ -366,7 +379,7 @@
|
|
|
366
379
|
Now you can override configuration like `useDefineForClassFields` using `tools.swc`.
|
|
367
380
|
|
|
368
381
|
```js
|
|
369
|
-
import { defineConfig } from
|
|
382
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
370
383
|
|
|
371
384
|
export default defineConfig({
|
|
372
385
|
tools: {
|
|
@@ -378,7 +391,7 @@
|
|
|
378
391
|
},
|
|
379
392
|
},
|
|
380
393
|
},
|
|
381
|
-
})
|
|
394
|
+
});
|
|
382
395
|
```
|
|
383
396
|
|
|
384
397
|
- Updated dependencies [[`f1ca29b`](https://github.com/lynx-family/lynx-stack/commit/f1ca29bd766377dd46583f15e1e75bca447699cd)]:
|
|
@@ -554,7 +567,7 @@
|
|
|
554
567
|
You may turn it off using `output.minify.css: false`:
|
|
555
568
|
|
|
556
569
|
```js
|
|
557
|
-
import { defineConfig } from
|
|
570
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
558
571
|
|
|
559
572
|
export default defineConfig({
|
|
560
573
|
output: {
|
|
@@ -562,18 +575,18 @@
|
|
|
562
575
|
css: false,
|
|
563
576
|
},
|
|
564
577
|
},
|
|
565
|
-
})
|
|
578
|
+
});
|
|
566
579
|
```
|
|
567
580
|
|
|
568
581
|
Or you may use [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) to use `cssnano` as CSS minimizer.
|
|
569
582
|
|
|
570
583
|
```js
|
|
571
|
-
import { defineConfig } from
|
|
572
|
-
import { pluginCssMinimizer } from
|
|
584
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
585
|
+
import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
|
|
573
586
|
|
|
574
587
|
export default defineConfig({
|
|
575
588
|
plugins: [pluginCssMinimizer()],
|
|
576
|
-
})
|
|
589
|
+
});
|
|
577
590
|
```
|
|
578
591
|
|
|
579
592
|
### Patch Changes
|
|
@@ -653,18 +666,18 @@
|
|
|
653
666
|
- e8039f2: Add `defineDCE` in plugin options. Often used to define custom macros.
|
|
654
667
|
|
|
655
668
|
```js
|
|
656
|
-
import { pluginReactLynx } from
|
|
657
|
-
import { defineConfig } from
|
|
669
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
670
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
658
671
|
|
|
659
672
|
export default defineConfig({
|
|
660
673
|
plugins: [
|
|
661
674
|
pluginReactLynx({
|
|
662
675
|
defineDCE: {
|
|
663
|
-
__SOME_FALSE_DEFINE__:
|
|
676
|
+
__SOME_FALSE_DEFINE__: "false",
|
|
664
677
|
},
|
|
665
678
|
}),
|
|
666
679
|
],
|
|
667
|
-
})
|
|
680
|
+
});
|
|
668
681
|
```
|
|
669
682
|
|
|
670
683
|
Different from `define` provided by bundlers like webpack, `defineDCE` works at transform time and a extra DCE (Dead Code Elimination) pass will be performed.
|
|
@@ -672,20 +685,20 @@
|
|
|
672
685
|
For example, `import` initialized by dead code will be removed:
|
|
673
686
|
|
|
674
687
|
```js
|
|
675
|
-
import { foo } from
|
|
688
|
+
import { foo } from "bar";
|
|
676
689
|
|
|
677
690
|
if (__SOME_FALSE_DEFINE__) {
|
|
678
|
-
foo()
|
|
679
|
-
console.log(
|
|
691
|
+
foo();
|
|
692
|
+
console.log("dead code");
|
|
680
693
|
} else {
|
|
681
|
-
console.log(
|
|
694
|
+
console.log("reachable code");
|
|
682
695
|
}
|
|
683
696
|
```
|
|
684
697
|
|
|
685
698
|
will be transformed to:
|
|
686
699
|
|
|
687
700
|
```js
|
|
688
|
-
console.log(
|
|
701
|
+
console.log("reachable code");
|
|
689
702
|
```
|
|
690
703
|
|
|
691
704
|
- Updated dependencies [8dd6cca]
|
|
@@ -728,18 +741,18 @@
|
|
|
728
741
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
729
742
|
|
|
730
743
|
```js
|
|
731
|
-
import { pluginReactLynx } from
|
|
732
|
-
import { defineConfig } from
|
|
744
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
745
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
733
746
|
|
|
734
747
|
export default defineConfig({
|
|
735
748
|
plugins: [
|
|
736
749
|
pluginReactLynx({
|
|
737
750
|
compat: {
|
|
738
|
-
removeComponentAttrRegex:
|
|
751
|
+
removeComponentAttrRegex: "YOUR REGEX",
|
|
739
752
|
},
|
|
740
753
|
}),
|
|
741
754
|
],
|
|
742
|
-
})
|
|
755
|
+
});
|
|
743
756
|
```
|
|
744
757
|
|
|
745
758
|
NOTE: This feature is deprecated and will be removed in the future. Use CodeMod instead.
|
|
@@ -758,11 +771,11 @@
|
|
|
758
771
|
|
|
759
772
|
```javascript
|
|
760
773
|
// bar.ts
|
|
761
|
-
import
|
|
774
|
+
import "background-only";
|
|
762
775
|
|
|
763
776
|
export const bar = () => {
|
|
764
|
-
return
|
|
765
|
-
}
|
|
777
|
+
return "bar";
|
|
778
|
+
};
|
|
766
779
|
```
|
|
767
780
|
|
|
768
781
|
If `bar` is called in `main-thread`, build time error will be triggered.
|
|
@@ -771,15 +784,15 @@
|
|
|
771
784
|
|
|
772
785
|
```tsx
|
|
773
786
|
// App.tsx
|
|
774
|
-
import { bar } from
|
|
787
|
+
import { bar } from "./bar.js";
|
|
775
788
|
|
|
776
789
|
function App() {
|
|
777
|
-
bar()
|
|
790
|
+
bar();
|
|
778
791
|
return (
|
|
779
792
|
<view>
|
|
780
793
|
<text>Hello, Lynx x rspeedy</text>
|
|
781
794
|
</view>
|
|
782
|
-
)
|
|
795
|
+
);
|
|
783
796
|
}
|
|
784
797
|
```
|
|
785
798
|
|
package/dist/index.js
CHANGED
|
@@ -512,20 +512,30 @@ function applyLoaders(api, options) {
|
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh';
|
|
515
|
-
const refresh_require = createRequire(import.meta.url);
|
|
516
515
|
function applyRefresh(api) {
|
|
517
|
-
api.modifyWebpackChain((chain, { CHAIN_ID, isProd })=>{
|
|
518
|
-
if (!isProd) applyRefreshRules(chain, CHAIN_ID, ReactRefreshWebpackPlugin);
|
|
516
|
+
api.modifyWebpackChain(async (chain, { CHAIN_ID, isProd })=>{
|
|
517
|
+
if (!isProd) await applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshWebpackPlugin);
|
|
519
518
|
});
|
|
520
|
-
api.modifyBundlerChain((chain, { isProd, CHAIN_ID })=>{
|
|
519
|
+
api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID })=>{
|
|
521
520
|
if (!isProd) {
|
|
522
|
-
|
|
523
|
-
|
|
521
|
+
const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
|
|
522
|
+
await Promise.all([
|
|
523
|
+
applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshRspackPlugin),
|
|
524
|
+
resolve('@lynx-js/react/refresh').then((refresh)=>{
|
|
525
|
+
chain.resolve.alias.set('@lynx-js/react/refresh$', refresh);
|
|
526
|
+
})
|
|
527
|
+
]);
|
|
524
528
|
}
|
|
525
529
|
});
|
|
526
530
|
}
|
|
527
|
-
function applyRefreshRules(chain, CHAIN_ID, ReactRefreshPlugin) {
|
|
528
|
-
|
|
531
|
+
async function applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshPlugin) {
|
|
532
|
+
const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
|
|
533
|
+
const [reactRuntime, refresh, workletRuntime] = await Promise.all([
|
|
534
|
+
resolve('@lynx-js/react/package.json'),
|
|
535
|
+
resolve('@lynx-js/react/refresh'),
|
|
536
|
+
resolve('@lynx-js/react/worklet-runtime')
|
|
537
|
+
]);
|
|
538
|
+
chain.plugin(PLUGIN_NAME_REACT_REFRESH).before(CHAIN_ID.PLUGIN.HMR).use(ReactRefreshPlugin).end().module.rule('react:refresh').issuerLayer(LAYERS.BACKGROUND).before(CHAIN_ID.RULE.JS).test(/\.[jt]sx$/).exclude.add(/node_modules/).add(external_node_path_["default"].dirname(reactRuntime)).add(external_node_path_["default"].dirname(refresh)).add(external_node_path_["default"].dirname(workletRuntime)).add(ReactRefreshPlugin.loader).end().use('ReactRefresh').loader(ReactRefreshPlugin.loader).options({}).end().end().end().end();
|
|
529
539
|
}
|
|
530
540
|
const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
|
|
531
541
|
const applySplitChunksRule = (api)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-rsbuild-plugin-canary",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2-canary-20251010-e21c4e23",
|
|
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.6.4",
|
|
36
|
-
"@lynx-js/react-alias-rsbuild-plugin": "npm:@lynx-js/react-alias-rsbuild-plugin-canary@0.11.
|
|
36
|
+
"@lynx-js/react-alias-rsbuild-plugin": "npm:@lynx-js/react-alias-rsbuild-plugin-canary@0.11.2-canary-20251010-e21c4e23",
|
|
37
37
|
"@lynx-js/react-refresh-webpack-plugin": "npm:@lynx-js/react-refresh-webpack-plugin-canary@0.3.4",
|
|
38
38
|
"@lynx-js/react-webpack-plugin": "npm:@lynx-js/react-webpack-plugin-canary@0.7.1",
|
|
39
39
|
"@lynx-js/runtime-wrapper-webpack-plugin": "npm:@lynx-js/runtime-wrapper-webpack-plugin-canary@0.1.3",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"rsbuild-plugin-arethetypeswrong": "0.1.1",
|
|
51
51
|
"rsbuild-plugin-publint": "0.3.3",
|
|
52
52
|
"tailwindcss": "^3.4.17",
|
|
53
|
-
"type-fest": "^
|
|
53
|
+
"type-fest": "^5.0.1",
|
|
54
54
|
"typia": "9.7.2",
|
|
55
55
|
"typia-rspack-plugin": "2.2.2",
|
|
56
|
-
"@lynx-js/react": "npm:@lynx-js/react-canary@0.114.
|
|
56
|
+
"@lynx-js/react": "npm:@lynx-js/react-canary@0.114.2-canary-20251010-e21c4e23",
|
|
57
57
|
"@lynx-js/react-transform": "0.2.0",
|
|
58
|
-
"@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.11.
|
|
58
|
+
"@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.11.6-canary-20251010-e21c4e23",
|
|
59
59
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|