@lynx-js/react-rsbuild-plugin 0.18.3 → 0.19.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 +37 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +41 -4
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @lynx-js/react-rsbuild-plugin
|
|
2
2
|
|
|
3
|
+
## 0.19.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Apply the Lynx build engine automatically when it is not already applied, so `pluginReactLynx` works with plain Rsbuild. ([#3578](https://github.com/lynx-family/lynx-stack/pull/3578))
|
|
8
|
+
|
|
9
|
+
- Read the bundle filename from the Rsbuild config instead of the Rspeedy API. ([#3570](https://github.com/lynx-family/lynx-stack/pull/3570))
|
|
10
|
+
|
|
11
|
+
- Emit the Lynx template for callers other than `rslib` and `rstest`. ([#3572](https://github.com/lynx-family/lynx-stack/pull/3572))
|
|
12
|
+
|
|
13
|
+
- Widen the `@lynx-js/react` peer dependency range to include 0.125. ([#3551](https://github.com/lynx-family/lynx-stack/pull/3551))
|
|
14
|
+
- Updated dependencies [[`1d08862`](https://github.com/lynx-family/lynx-stack/commit/1d08862ef9a1883fe98f2b9f7dce59d092d14d68), [`99ed745`](https://github.com/lynx-family/lynx-stack/commit/99ed7451d190cd18a45f78f731141994104a054b), [`0d10b79`](https://github.com/lynx-family/lynx-stack/commit/0d10b796d219e6f661709885d9ff2a4e61f4e65b), [`0d10b79`](https://github.com/lynx-family/lynx-stack/commit/0d10b796d219e6f661709885d9ff2a4e61f4e65b), [`0d10b79`](https://github.com/lynx-family/lynx-stack/commit/0d10b796d219e6f661709885d9ff2a4e61f4e65b), [`0d10b79`](https://github.com/lynx-family/lynx-stack/commit/0d10b796d219e6f661709885d9ff2a4e61f4e65b), [`92b54ed`](https://github.com/lynx-family/lynx-stack/commit/92b54edba5adea2a4ddd355c821ff25205273479), [`37497d5`](https://github.com/lynx-family/lynx-stack/commit/37497d58fe4e0762d687001d61181ec5e0e650b9)]:
|
|
15
|
+
- @lynx-js/react-webpack-plugin@0.11.1
|
|
16
|
+
- @lynx-js/rsbuild-plugin@0.0.3
|
|
17
|
+
- @lynx-js/react-alias-rsbuild-plugin@0.19.1
|
|
18
|
+
- @lynx-js/use-sync-external-store@1.5.0
|
|
19
|
+
- @lynx-js/react-refresh-webpack-plugin@0.4.2
|
|
20
|
+
- @lynx-js/css-extract-webpack-plugin@0.10.1
|
|
21
|
+
- @lynx-js/template-webpack-plugin@0.15.2
|
|
22
|
+
|
|
23
|
+
## 0.19.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Register the snapshot and worklet definitions collected from the background build on the main thread, so a definition the main-thread bundle dropped no longer fails with `Snapshot not found`. ([#3393](https://github.com/lynx-family/lynx-stack/pull/3393))
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Add `compat.transformLegacyEventAttributeNames` to disable legacy event attribute-name conversion independently from other compatibility transforms. ([#3475](https://github.com/lynx-family/lynx-stack/pull/3475))
|
|
32
|
+
- Updated dependencies [[`21528f1`](https://github.com/lynx-family/lynx-stack/commit/21528f12c347564c40bc0c15de3df7db5ce85afe), [`f391460`](https://github.com/lynx-family/lynx-stack/commit/f391460d176eb84cb30faa0ca1644be388ce216a), [`c58b6f9`](https://github.com/lynx-family/lynx-stack/commit/c58b6f91cf7084d2585f42e00db3dd699c27ed61), [`6cc9624`](https://github.com/lynx-family/lynx-stack/commit/6cc9624fb54dc7f73b6e68e49e2322b8136d3418), [`328f712`](https://github.com/lynx-family/lynx-stack/commit/328f7125d1881cf438e58aa749f1e554a756b652), [`c58b6f9`](https://github.com/lynx-family/lynx-stack/commit/c58b6f91cf7084d2585f42e00db3dd699c27ed61)]:
|
|
33
|
+
- @lynx-js/react-webpack-plugin@0.11.0
|
|
34
|
+
- @lynx-js/react-alias-rsbuild-plugin@0.19.0
|
|
35
|
+
- @lynx-js/template-webpack-plugin@0.15.1
|
|
36
|
+
- @lynx-js/react-refresh-webpack-plugin@0.4.2
|
|
37
|
+
- @lynx-js/use-sync-external-store@1.5.0
|
|
38
|
+
- @lynx-js/css-extract-webpack-plugin@0.10.1
|
|
39
|
+
|
|
3
40
|
## 0.18.3
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,17 @@ export declare interface CompatVisitorConfig {
|
|
|
227
227
|
* ```
|
|
228
228
|
*/
|
|
229
229
|
simplifyCtorLikeReactLynx2: boolean
|
|
230
|
+
/**
|
|
231
|
+
* @public
|
|
232
|
+
* Whether to transform legacy event attribute names on Lynx elements.
|
|
233
|
+
*
|
|
234
|
+
* When enabled, legacy event attributes such as `onClick` and
|
|
235
|
+
* `onClickCatch` are transformed to `bindtap` and `catchtap`.
|
|
236
|
+
* Disable this when another transform owns event attribute-name conversion.
|
|
237
|
+
*
|
|
238
|
+
* @defaultValue `true`
|
|
239
|
+
*/
|
|
240
|
+
transformLegacyEventAttributeNames?: boolean
|
|
230
241
|
/**
|
|
231
242
|
* @public
|
|
232
243
|
* Regular expression used to remove component attributes
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,32 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { pluginReactAlias } from "@lynx-js/react-alias-rsbuild-plugin";
|
|
3
3
|
import { LAYERS, ReactWebpackPlugin } from "@lynx-js/react-webpack-plugin";
|
|
4
4
|
import { LynxEncodePlugin, LynxTemplatePlugin, WebEncodePlugin } from "@lynx-js/template-webpack-plugin";
|
|
5
|
+
import { PLUGIN_LYNX_NAME, pluginLynx } from "@lynx-js/rsbuild-plugin";
|
|
5
6
|
import node_path from "node:path";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
8
|
import { RuntimeWrapperWebpackPlugin } from "@lynx-js/runtime-wrapper-webpack-plugin";
|
|
8
9
|
import { ReactRefreshRspackPlugin } from "@lynx-js/react-refresh-webpack-plugin";
|
|
10
|
+
const S_PLUGIN_LYNX_APPLIED = Symbol.for('@lynx-js/rsbuild-plugin:applied');
|
|
11
|
+
function pluginAutoLynx() {
|
|
12
|
+
return {
|
|
13
|
+
name: 'lynx:react:auto-lynx',
|
|
14
|
+
async setup (api) {
|
|
15
|
+
const { callerName } = api.context;
|
|
16
|
+
if ('rslib' === callerName || 'rstest' === callerName) return;
|
|
17
|
+
if (api.isPluginExists(PLUGIN_LYNX_NAME) || Object.hasOwn(api.context, S_PLUGIN_LYNX_APPLIED)) return;
|
|
18
|
+
Object.defineProperty(api.context, S_PLUGIN_LYNX_APPLIED, {
|
|
19
|
+
value: true
|
|
20
|
+
});
|
|
21
|
+
const original = api.getRsbuildConfig('original');
|
|
22
|
+
for (const plugin of pluginLynx()){
|
|
23
|
+
const { action } = api.context;
|
|
24
|
+
if ('function' != typeof plugin.apply || plugin.apply(original, {
|
|
25
|
+
action
|
|
26
|
+
})) await plugin.setup(api);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
9
31
|
const DETECT_IMPORT_ERROR = 'react:detect-import-error';
|
|
10
32
|
const ALIAS_BACKGROUND_ONLY_MAIN = 'react:alias-background-only-main';
|
|
11
33
|
const ALIAS_BACKGROUND_ONLY_BACKGROUND = 'react:alias-background-only-background';
|
|
@@ -138,13 +160,15 @@ function applyEntry(api, options) {
|
|
|
138
160
|
const lazyBundleFetcher = resolveLazyBundleFetcher(targetSdkVersion);
|
|
139
161
|
api.modifyBundlerChain(async (chain, { environment, isDev, isProd })=>{
|
|
140
162
|
const mainThreadChunks = [];
|
|
163
|
+
const entryPairs = [];
|
|
141
164
|
const rsbuildConfig = api.getRsbuildConfig();
|
|
142
165
|
const userConfig = api.getRsbuildConfig('original');
|
|
143
166
|
const chunkSplitStrategy = userConfig.performance?.chunkSplit?.strategy;
|
|
144
167
|
const enableChunkSplitting = void 0 === userConfig.splitChunks ? chunkSplitStrategy ? 'all-in-one' !== chunkSplitStrategy : false !== rsbuildConfig.splitChunks : false !== rsbuildConfig.splitChunks;
|
|
145
168
|
const rspeedyConfig = 'rspeedy' === api.context.callerName ? api.useExposed(Symbol.for('rspeedy.api'))?.config : void 0;
|
|
146
|
-
const
|
|
147
|
-
|
|
169
|
+
const bundleFilenameConfig = api.getRsbuildConfig('original').output?.filename;
|
|
170
|
+
const emitTemplate = 'rslib' !== api.context.callerName && 'rstest' !== api.context.callerName;
|
|
171
|
+
if (emitTemplate) {
|
|
148
172
|
const entries = chain.entryPoints.entries() ?? {};
|
|
149
173
|
const isLynx = 'lynx' === environment.name || environment.name.startsWith('lynx-');
|
|
150
174
|
const isWeb = 'web' === environment.name || environment.name.startsWith('web-');
|
|
@@ -154,7 +178,7 @@ function applyEntry(api, options) {
|
|
|
154
178
|
chain.entryPoints.clear();
|
|
155
179
|
Object.entries(entries).forEach(([entryName, entryPoint])=>{
|
|
156
180
|
const { imports } = getChunks(entryName, entryPoint.values());
|
|
157
|
-
const bundleFilename =
|
|
181
|
+
const bundleFilename = bundleFilenameConfig?.bundle ?? bundleFilenameConfig?.template;
|
|
158
182
|
let templateFilename;
|
|
159
183
|
let lazyBundleFilename;
|
|
160
184
|
if ('function' == typeof bundleFilename) {
|
|
@@ -174,6 +198,10 @@ function applyEntry(api, options) {
|
|
|
174
198
|
const backgroundName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', getBackgroundFilename(entryName, environment.config, isProd, experimental_isLazyBundle));
|
|
175
199
|
const backgroundEntry = entryName;
|
|
176
200
|
mainThreadChunks.push(mainThreadName);
|
|
201
|
+
entryPairs.push({
|
|
202
|
+
mainThread: mainThreadEntry,
|
|
203
|
+
background: backgroundEntry
|
|
204
|
+
});
|
|
177
205
|
chain.entry(mainThreadEntry).add({
|
|
178
206
|
layer: LAYERS.MAIN_THREAD,
|
|
179
207
|
import: imports,
|
|
@@ -273,6 +301,7 @@ function applyEntry(api, options) {
|
|
|
273
301
|
globalPropsMode,
|
|
274
302
|
enableSSR,
|
|
275
303
|
mainThreadChunks,
|
|
304
|
+
entryPairs,
|
|
276
305
|
extractStr,
|
|
277
306
|
experimental_isLazyBundle,
|
|
278
307
|
experimental_useElementTemplate: options.experimental_useElementTemplate,
|
|
@@ -676,7 +705,7 @@ const validateConfig = (()=>{
|
|
|
676
705
|
if (void 0 === value) return true;
|
|
677
706
|
return false;
|
|
678
707
|
}));
|
|
679
|
-
const _io1 = (input, _exceptionable = true)=>(void 0 === input.componentsPkg || Array.isArray(input.componentsPkg) && input.componentsPkg.every((elem, _index2)=>"string" == typeof elem)) && (void 0 === input.oldRuntimePkg || Array.isArray(input.oldRuntimePkg) && input.oldRuntimePkg.every((elem, _index3)=>"string" == typeof elem)) && (void 0 === input.newRuntimePkg || "string" == typeof input.newRuntimePkg) && (void 0 === input.additionalComponentAttributes || Array.isArray(input.additionalComponentAttributes) && input.additionalComponentAttributes.every((elem, _index4)=>"string" == typeof elem)) && null !== input.addComponentElement && (void 0 === input.addComponentElement || "boolean" == typeof input.addComponentElement || "object" == typeof input.addComponentElement && null !== input.addComponentElement && _io2(input.addComponentElement, _exceptionable)) && (void 0 === input.simplifyCtorLikeReactLynx2 || "boolean" == typeof input.simplifyCtorLikeReactLynx2) && (void 0 === input.removeComponentAttrRegex || "string" == typeof input.removeComponentAttrRegex) && (void 0 === input.disableDeprecatedWarning || "boolean" == typeof input.disableDeprecatedWarning) && null !== input.darkMode && (void 0 === input.darkMode || "boolean" == typeof input.darkMode || "object" == typeof input.darkMode && null !== input.darkMode && _io3(input.darkMode, _exceptionable)) && (void 0 === input.legacySlot || "boolean" == typeof input.legacySlot) && (void 0 === input.disableCreateSelectorQueryIncompatibleWarning || "boolean" == typeof input.disableCreateSelectorQueryIncompatibleWarning) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
|
|
708
|
+
const _io1 = (input, _exceptionable = true)=>(void 0 === input.componentsPkg || Array.isArray(input.componentsPkg) && input.componentsPkg.every((elem, _index2)=>"string" == typeof elem)) && (void 0 === input.oldRuntimePkg || Array.isArray(input.oldRuntimePkg) && input.oldRuntimePkg.every((elem, _index3)=>"string" == typeof elem)) && (void 0 === input.newRuntimePkg || "string" == typeof input.newRuntimePkg) && (void 0 === input.additionalComponentAttributes || Array.isArray(input.additionalComponentAttributes) && input.additionalComponentAttributes.every((elem, _index4)=>"string" == typeof elem)) && null !== input.addComponentElement && (void 0 === input.addComponentElement || "boolean" == typeof input.addComponentElement || "object" == typeof input.addComponentElement && null !== input.addComponentElement && _io2(input.addComponentElement, _exceptionable)) && (void 0 === input.simplifyCtorLikeReactLynx2 || "boolean" == typeof input.simplifyCtorLikeReactLynx2) && (void 0 === input.transformLegacyEventAttributeNames || "boolean" == typeof input.transformLegacyEventAttributeNames) && (void 0 === input.removeComponentAttrRegex || "string" == typeof input.removeComponentAttrRegex) && (void 0 === input.disableDeprecatedWarning || "boolean" == typeof input.disableDeprecatedWarning) && null !== input.darkMode && (void 0 === input.darkMode || "boolean" == typeof input.darkMode || "object" == typeof input.darkMode && null !== input.darkMode && _io3(input.darkMode, _exceptionable)) && (void 0 === input.legacySlot || "boolean" == typeof input.legacySlot) && (void 0 === input.disableCreateSelectorQueryIncompatibleWarning || "boolean" == typeof input.disableCreateSelectorQueryIncompatibleWarning) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
|
|
680
709
|
if ([
|
|
681
710
|
"componentsPkg",
|
|
682
711
|
"oldRuntimePkg",
|
|
@@ -684,6 +713,7 @@ const validateConfig = (()=>{
|
|
|
684
713
|
"additionalComponentAttributes",
|
|
685
714
|
"addComponentElement",
|
|
686
715
|
"simplifyCtorLikeReactLynx2",
|
|
716
|
+
"transformLegacyEventAttributeNames",
|
|
687
717
|
"removeComponentAttrRegex",
|
|
688
718
|
"disableDeprecatedWarning",
|
|
689
719
|
"darkMode",
|
|
@@ -1047,6 +1077,11 @@ const validateConfig = (()=>{
|
|
|
1047
1077
|
path: _path + ".simplifyCtorLikeReactLynx2",
|
|
1048
1078
|
expected: "(boolean | undefined)",
|
|
1049
1079
|
value: input.simplifyCtorLikeReactLynx2
|
|
1080
|
+
}, _errorFactory)) && (void 0 === input.transformLegacyEventAttributeNames || "boolean" == typeof input.transformLegacyEventAttributeNames || _assertGuard(_exceptionable, {
|
|
1081
|
+
method: "typia.createAssertEquals",
|
|
1082
|
+
path: _path + ".transformLegacyEventAttributeNames",
|
|
1083
|
+
expected: "(boolean | undefined)",
|
|
1084
|
+
value: input.transformLegacyEventAttributeNames
|
|
1050
1085
|
}, _errorFactory)) && (void 0 === input.removeComponentAttrRegex || "string" == typeof input.removeComponentAttrRegex || _assertGuard(_exceptionable, {
|
|
1051
1086
|
method: "typia.createAssertEquals",
|
|
1052
1087
|
path: _path + ".removeComponentAttrRegex",
|
|
@@ -1090,6 +1125,7 @@ const validateConfig = (()=>{
|
|
|
1090
1125
|
"additionalComponentAttributes",
|
|
1091
1126
|
"addComponentElement",
|
|
1092
1127
|
"simplifyCtorLikeReactLynx2",
|
|
1128
|
+
"transformLegacyEventAttributeNames",
|
|
1093
1129
|
"removeComponentAttrRegex",
|
|
1094
1130
|
"disableDeprecatedWarning",
|
|
1095
1131
|
"darkMode",
|
|
@@ -1415,6 +1451,7 @@ function pluginReactLynx(userOptions) {
|
|
|
1415
1451
|
engineVersion
|
|
1416
1452
|
});
|
|
1417
1453
|
return [
|
|
1454
|
+
pluginAutoLynx(),
|
|
1418
1455
|
pluginReactAlias({
|
|
1419
1456
|
lazy: resolvedOptions.experimental_isLazyBundle,
|
|
1420
1457
|
elementTemplate: resolvedOptions.experimental_useElementTemplate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-rsbuild-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "A rsbuild plugin for ReactLynx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rsbuild",
|
|
@@ -34,36 +34,37 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"tiny-invariant": "^1.3.3",
|
|
36
36
|
"@lynx-js/css-extract-webpack-plugin": "0.10.1",
|
|
37
|
-
"@lynx-js/react-alias-rsbuild-plugin": "0.
|
|
38
|
-
"@lynx-js/react-refresh-webpack-plugin": "0.4.
|
|
39
|
-
"@lynx-js/react-webpack-plugin": "0.
|
|
37
|
+
"@lynx-js/react-alias-rsbuild-plugin": "0.19.1",
|
|
38
|
+
"@lynx-js/react-refresh-webpack-plugin": "0.4.2",
|
|
39
|
+
"@lynx-js/react-webpack-plugin": "0.11.1",
|
|
40
|
+
"@lynx-js/rsbuild-plugin": "0.0.3",
|
|
40
41
|
"@lynx-js/runtime-wrapper-webpack-plugin": "0.2.3",
|
|
41
|
-
"@lynx-js/template-webpack-plugin": "0.15.
|
|
42
|
+
"@lynx-js/template-webpack-plugin": "0.15.2",
|
|
42
43
|
"@lynx-js/use-sync-external-store": "1.5.0",
|
|
43
44
|
"background-only": "^0.0.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@microsoft/api-extractor": "7.58.12",
|
|
47
|
-
"@rsbuild/core": "2.1.
|
|
48
|
+
"@rsbuild/core": "2.1.10",
|
|
48
49
|
"@rsbuild/plugin-sass": "2.0.1",
|
|
49
50
|
"@rsbuild/plugin-typed-css-modules": "1.2.4",
|
|
50
|
-
"@rstest/core": "0.11.
|
|
51
|
+
"@rstest/core": "0.11.6",
|
|
51
52
|
"rsbuild-plugin-arethetypeswrong": "0.3.1",
|
|
52
53
|
"rsbuild-plugin-publint": "1.0.0",
|
|
53
|
-
"source-map": "^0.
|
|
54
|
+
"source-map": "^0.8.0",
|
|
54
55
|
"tailwindcss": "^3.4.19",
|
|
55
56
|
"type-fest": "^5.8.0",
|
|
56
57
|
"typia": "12.1.1",
|
|
57
58
|
"typia-rspack-plugin": "3.0.1",
|
|
58
|
-
"@lynx-js/config-rsbuild-plugin": "0.2.2",
|
|
59
59
|
"@lynx-js/debug-metadata": "0.1.0",
|
|
60
|
-
"@lynx-js/
|
|
60
|
+
"@lynx-js/config-rsbuild-plugin": "0.2.2",
|
|
61
|
+
"@lynx-js/react": "0.125.0",
|
|
61
62
|
"@lynx-js/react-transform": "0.2.0",
|
|
62
|
-
"@lynx-js/rspeedy": "0.16.
|
|
63
|
+
"@lynx-js/rspeedy": "0.16.5",
|
|
63
64
|
"@lynx-js/test-tools": "0.0.0"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"@lynx-js/react": "^0.
|
|
67
|
+
"@lynx-js/react": "^0.124.0 || ^0.125.0"
|
|
67
68
|
},
|
|
68
69
|
"peerDependenciesMeta": {
|
|
69
70
|
"@lynx-js/react": {
|