@lynx-js/react-rsbuild-plugin-canary 0.12.6-canary-20260119-609be14f → 0.12.6-canary-20260119-51d6b269

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -4
  2. package/dist/208.js +124 -104
  3. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # @lynx-js/react-rsbuild-plugin
2
2
 
3
- ## 0.12.6-canary-20260119071406-609be14f6b3af9738bb8b7980d4d3c9b684f963b
3
+ ## 0.12.6-canary-20260119071537-51d6b26913abc28420373381de059cc3d48264eb
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - Support using `pluginReactLynx` in Rslib. ([#2114](https://github.com/lynx-family/lynx-stack/pull/2114))
8
+
7
9
  - Updated dependencies [[`a7a2ad7`](https://github.com/lynx-family/lynx-stack/commit/a7a2ad79c02c7051f7ae46b2e3cc63484decc101), [`82b4052`](https://github.com/lynx-family/lynx-stack/commit/82b4052d9f1292c161ba6f428a24c759cca11123), [`4cd7182`](https://github.com/lynx-family/lynx-stack/commit/4cd71828a073e27ac3a2f5accded53e42e663215)]:
8
- - @lynx-js/react@0.116.0-canary-20260119071406-609be14f6b3af9738bb8b7980d4d3c9b684f963b
9
- - @lynx-js/template-webpack-plugin@0.10.2-canary-20260119071406-609be14f6b3af9738bb8b7980d4d3c9b684f963b
10
- - @lynx-js/react-alias-rsbuild-plugin@0.12.6-canary-20260119071406-609be14f6b3af9738bb8b7980d4d3c9b684f963b
10
+ - @lynx-js/react@0.116.0-canary-20260119071537-51d6b26913abc28420373381de059cc3d48264eb
11
+ - @lynx-js/template-webpack-plugin@0.10.2-canary-20260119071537-51d6b26913abc28420373381de059cc3d48264eb
12
+ - @lynx-js/react-alias-rsbuild-plugin@0.12.6-canary-20260119071537-51d6b26913abc28420373381de059cc3d48264eb
11
13
  - @lynx-js/use-sync-external-store@1.5.0
12
14
  - @lynx-js/react-refresh-webpack-plugin@0.3.4
13
15
  - @lynx-js/react-webpack-plugin@0.7.3
package/dist/208.js CHANGED
@@ -200,111 +200,114 @@ const DEFAULT_FILENAME_HASH = '.[contenthash:8]';
200
200
  const EMPTY_HASH = '';
201
201
  function applyEntry(api, options) {
202
202
  const { compat, customCSSInheritanceList, debugInfoOutside, defaultDisplayLinear, enableAccessibilityElement, enableCSSInheritance, enableCSSInvalidation, enableCSSSelector, enableNewGesture, enableRemoveCSSScope, firstScreenSyncTiming, enableSSR, removeDescendantSelectorScope, targetSdkVersion, extractStr: originalExtractStr, experimental_isLazyBundle } = options;
203
- const { config, logger } = api.useExposed(Symbol.for('rspeedy.api'));
204
203
  api.modifyBundlerChain(async (chain, { environment, isDev, isProd })=>{
205
- const entries = chain.entryPoints.entries() ?? {};
206
- const isLynx = 'lynx' === environment.name || environment.name.startsWith('lynx-');
207
- const isWeb = 'web' === environment.name || environment.name.startsWith('web-');
208
- const { hmr, liveReload } = environment.config.dev ?? {};
209
- const enabledHMR = isDev && !isWeb && false !== hmr;
210
- const enabledLiveReload = isDev && !isWeb && false !== liveReload;
211
- chain.entryPoints.clear();
212
204
  const mainThreadChunks = [];
213
- Object.entries(entries).forEach(([entryName, entryPoint])=>{
214
- const { imports } = getChunks(entryName, entryPoint.values());
215
- const templateFilename = ('object' == typeof config.output?.filename ? config.output.filename.bundle ?? config.output.filename.template : config.output?.filename) ?? '[name].[platform].bundle';
216
- const mainThreadEntry = `${entryName}__main-thread`;
217
- const mainThreadName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', `${entryName}/main-thread.js`);
218
- const backgroundName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', getBackgroundFilename(entryName, environment.config, isProd, experimental_isLazyBundle));
219
- const backgroundEntry = entryName;
220
- mainThreadChunks.push(mainThreadName);
221
- chain.entry(mainThreadEntry).add({
222
- layer: LAYERS.MAIN_THREAD,
223
- import: imports,
224
- filename: mainThreadName
225
- }).when(enabledHMR, (entry)=>{
226
- const require = createRequire(import.meta.url);
227
- entry.prepend({
228
- layer: LAYERS.MAIN_THREAD,
229
- import: require.resolve('@lynx-js/css-extract-webpack-plugin/runtime/hotModuleReplacement.lepus.cjs')
230
- });
231
- }).end().entry(backgroundEntry).add({
232
- layer: LAYERS.BACKGROUND,
233
- import: imports,
234
- filename: backgroundName
235
- }).when(enabledHMR, (entry)=>{
236
- entry.prepend({
237
- layer: LAYERS.BACKGROUND,
238
- import: '@rspack/core/hot/dev-server'
239
- }).prepend({
240
- layer: LAYERS.BACKGROUND,
241
- import: '@lynx-js/react/refresh'
242
- });
243
- }).when(enabledHMR || enabledLiveReload, (entry)=>{
244
- entry.prepend({
245
- layer: LAYERS.BACKGROUND,
246
- import: '@lynx-js/webpack-dev-transport/client'
247
- });
248
- }).end().plugin(`${PLUGIN_NAME_TEMPLATE}-${entryName}`).use(LynxTemplatePlugin, [
249
- {
250
- dsl: 'react_nodiff',
251
- chunks: [
252
- mainThreadEntry,
253
- backgroundEntry
254
- ],
255
- filename: templateFilename.replaceAll('[name]', entryName).replaceAll('[platform]', environment.name),
256
- intermediate: node_path.posix.join(DEFAULT_DIST_PATH_INTERMEDIATE, entryName),
257
- customCSSInheritanceList,
258
- debugInfoOutside,
259
- defaultDisplayLinear,
260
- enableA11y: true,
261
- enableAccessibilityElement,
262
- enableCSSInheritance,
263
- enableCSSInvalidation,
264
- enableCSSSelector,
265
- enableNewGesture,
266
- enableRemoveCSSScope: enableRemoveCSSScope ?? true,
267
- removeDescendantSelectorScope,
268
- targetSdkVersion,
269
- experimental_isLazyBundle,
270
- cssPlugins: []
271
- }
272
- ]).end();
273
- });
274
205
  const rsbuildConfig = api.getRsbuildConfig();
275
206
  const userConfig = api.getRsbuildConfig('original');
276
207
  const enableChunkSplitting = rsbuildConfig.performance?.chunkSplit?.strategy !== 'all-in-one';
277
- if (isLynx) {
278
- let inlineScripts;
279
- inlineScripts = experimental_isLazyBundle ? true : environment.config.output?.inlineScripts ?? !enableChunkSplitting;
280
- chain.plugin(PLUGIN_NAME_RUNTIME_WRAPPER).use(RuntimeWrapperWebpackPlugin, [
281
- {
282
- injectVars (vars) {
283
- const UNUSED_VARS = new Set([
284
- 'Card',
285
- 'Component',
286
- 'ReactLynx',
287
- 'Behavior'
288
- ]);
289
- return vars.map((name)=>{
290
- if (UNUSED_VARS.has(name)) return `__${name}`;
291
- return name;
292
- });
293
- },
294
- targetSdkVersion,
295
- test: /^(?!.*main-thread(?:\.[A-Fa-f0-9]*)?\.js$).*\.js$/,
296
- experimental_isLazyBundle
297
- }
298
- ]).end().plugin(`${LynxEncodePlugin.name}`).use(LynxEncodePlugin, [
299
- {
300
- inlineScripts
301
- }
302
- ]).end();
208
+ const isRspeedy = 'rspeedy' === api.context.callerName;
209
+ if (isRspeedy) {
210
+ const { config } = api.useExposed(Symbol.for('rspeedy.api'));
211
+ const entries = chain.entryPoints.entries() ?? {};
212
+ const isLynx = 'lynx' === environment.name || environment.name.startsWith('lynx-');
213
+ const isWeb = 'web' === environment.name || environment.name.startsWith('web-');
214
+ const { hmr, liveReload } = environment.config.dev ?? {};
215
+ const enabledHMR = isDev && !isWeb && false !== hmr;
216
+ const enabledLiveReload = isDev && !isWeb && false !== liveReload;
217
+ chain.entryPoints.clear();
218
+ Object.entries(entries).forEach(([entryName, entryPoint])=>{
219
+ const { imports } = getChunks(entryName, entryPoint.values());
220
+ const templateFilename = ('object' == typeof config.output?.filename ? config.output.filename.bundle ?? config.output.filename.template : config.output?.filename) ?? '[name].[platform].bundle';
221
+ const mainThreadEntry = `${entryName}__main-thread`;
222
+ const mainThreadName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', `${entryName}/main-thread.js`);
223
+ const backgroundName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', getBackgroundFilename(entryName, environment.config, isProd, experimental_isLazyBundle));
224
+ const backgroundEntry = entryName;
225
+ mainThreadChunks.push(mainThreadName);
226
+ chain.entry(mainThreadEntry).add({
227
+ layer: LAYERS.MAIN_THREAD,
228
+ import: imports,
229
+ filename: mainThreadName
230
+ }).when(enabledHMR, (entry)=>{
231
+ const require = createRequire(import.meta.url);
232
+ entry.prepend({
233
+ layer: LAYERS.MAIN_THREAD,
234
+ import: require.resolve('@lynx-js/css-extract-webpack-plugin/runtime/hotModuleReplacement.lepus.cjs')
235
+ });
236
+ }).end().entry(backgroundEntry).add({
237
+ layer: LAYERS.BACKGROUND,
238
+ import: imports,
239
+ filename: backgroundName
240
+ }).when(enabledHMR, (entry)=>{
241
+ entry.prepend({
242
+ layer: LAYERS.BACKGROUND,
243
+ import: '@rspack/core/hot/dev-server'
244
+ }).prepend({
245
+ layer: LAYERS.BACKGROUND,
246
+ import: '@lynx-js/react/refresh'
247
+ });
248
+ }).when(enabledHMR || enabledLiveReload, (entry)=>{
249
+ entry.prepend({
250
+ layer: LAYERS.BACKGROUND,
251
+ import: '@lynx-js/webpack-dev-transport/client'
252
+ });
253
+ }).end().plugin(`${PLUGIN_NAME_TEMPLATE}-${entryName}`).use(LynxTemplatePlugin, [
254
+ {
255
+ dsl: 'react_nodiff',
256
+ chunks: [
257
+ mainThreadEntry,
258
+ backgroundEntry
259
+ ],
260
+ filename: templateFilename.replaceAll('[name]', entryName).replaceAll('[platform]', environment.name),
261
+ intermediate: node_path.posix.join(DEFAULT_DIST_PATH_INTERMEDIATE, entryName),
262
+ customCSSInheritanceList,
263
+ debugInfoOutside,
264
+ defaultDisplayLinear,
265
+ enableA11y: true,
266
+ enableAccessibilityElement,
267
+ enableCSSInheritance,
268
+ enableCSSInvalidation,
269
+ enableCSSSelector,
270
+ enableNewGesture,
271
+ enableRemoveCSSScope: enableRemoveCSSScope ?? true,
272
+ removeDescendantSelectorScope,
273
+ targetSdkVersion,
274
+ experimental_isLazyBundle,
275
+ cssPlugins: []
276
+ }
277
+ ]).end();
278
+ });
279
+ if (isLynx) {
280
+ let inlineScripts;
281
+ inlineScripts = experimental_isLazyBundle ? true : environment.config.output?.inlineScripts ?? !enableChunkSplitting;
282
+ chain.plugin(PLUGIN_NAME_RUNTIME_WRAPPER).use(RuntimeWrapperWebpackPlugin, [
283
+ {
284
+ injectVars (vars) {
285
+ const UNUSED_VARS = new Set([
286
+ 'Card',
287
+ 'Component',
288
+ 'ReactLynx',
289
+ 'Behavior'
290
+ ]);
291
+ return vars.map((name)=>{
292
+ if (UNUSED_VARS.has(name)) return `__${name}`;
293
+ return name;
294
+ });
295
+ },
296
+ targetSdkVersion,
297
+ test: /^(?!.*main-thread(?:\.[A-Fa-f0-9]*)?\.js$).*\.js$/,
298
+ experimental_isLazyBundle
299
+ }
300
+ ]).end().plugin(`${LynxEncodePlugin.name}`).use(LynxEncodePlugin, [
301
+ {
302
+ inlineScripts
303
+ }
304
+ ]).end();
305
+ }
306
+ if (isWeb) chain.plugin(PLUGIN_NAME_WEB).use(WebEncodePlugin, []).end();
303
307
  }
304
- if (isWeb) chain.plugin(PLUGIN_NAME_WEB).use(WebEncodePlugin, []).end();
305
308
  let extractStr = originalExtractStr;
306
309
  if (enableChunkSplitting && originalExtractStr) {
307
- logger.warn('`extractStr` is changed to `false` because it is only supported in `all-in-one` chunkSplit strategy, please set `performance.chunkSplit.strategy` to `all-in-one` to use `extractStr.`');
310
+ (api.logger ?? console).warn('`extractStr` is changed to `false` because it is only supported in `all-in-one` chunkSplit strategy, please set `performance.chunkSplit.strategy` to `all-in-one` to use `extractStr.`');
308
311
  extractStr = false;
309
312
  }
310
313
  const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
@@ -428,6 +431,17 @@ function applyLoaders(api, options) {
428
431
  rule.uses.clear();
429
432
  });
430
433
  }
434
+ function applyNodeEnv(api) {
435
+ api.modifyEnvironmentConfig((userConfig, { mergeEnvironmentConfig })=>mergeEnvironmentConfig(userConfig, {
436
+ tools: {
437
+ rspack: {
438
+ optimization: {
439
+ nodeEnv: process.env['NODE_ENV'] ?? false
440
+ }
441
+ }
442
+ }
443
+ }));
444
+ }
431
445
  const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh';
432
446
  function applyRefresh(api) {
433
447
  api.modifyWebpackChain(async (chain, { CHAIN_ID, isProd })=>{
@@ -514,7 +528,14 @@ function applySWC(api) {
514
528
  }
515
529
  }
516
530
  }
517
- }, config));
531
+ }, config, {
532
+ tools: {
533
+ swc (config) {
534
+ delete config.env;
535
+ return config;
536
+ }
537
+ }
538
+ }));
518
539
  }
519
540
  function applyUseSyncExternalStore(api) {
520
541
  api.modifyBundlerChain(async (chain, { rspack })=>{
@@ -1130,13 +1151,14 @@ function pluginReactLynx(userOptions) {
1130
1151
  'lynx:config'
1131
1152
  ],
1132
1153
  setup (api) {
1154
+ const isRslib = 'rslib' === api.context.callerName;
1133
1155
  const exposedConfig = api.useExposed(Symbol.for('lynx.config'));
1134
1156
  if (exposedConfig) Object.keys(defaultOptions).forEach((key)=>{
1135
1157
  if (Object.hasOwn(exposedConfig.config, key)) Object.assign(resolvedOptions, {
1136
1158
  [key]: exposedConfig.config[key]
1137
1159
  });
1138
1160
  });
1139
- applyCSS(api, resolvedOptions);
1161
+ if (!isRslib) applyCSS(api, resolvedOptions);
1140
1162
  applyEntry(api, resolvedOptions);
1141
1163
  applyBackgroundOnly(api);
1142
1164
  applyGenerator(api, resolvedOptions);
@@ -1145,6 +1167,7 @@ function pluginReactLynx(userOptions) {
1145
1167
  applySplitChunksRule(api);
1146
1168
  applySWC(api);
1147
1169
  applyUseSyncExternalStore(api);
1170
+ if (isRslib) applyNodeEnv(api);
1148
1171
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
1149
1172
  const userConfig = api.getRsbuildConfig('original');
1150
1173
  if (void 0 === userConfig.source?.include) config = mergeRsbuildConfig(config, {
@@ -1179,13 +1202,10 @@ function pluginReactLynx(userOptions) {
1179
1202
  getLynxTemplatePluginHooks: LynxTemplatePlugin.getLynxTemplatePluginHooks.bind(LynxTemplatePlugin)
1180
1203
  }
1181
1204
  });
1182
- const rspeedyAPIs = api.useExposed(Symbol.for('rspeedy.api'));
1183
1205
  const require = createRequire(import.meta.url);
1184
1206
  const { version } = require('../package.json');
1185
- rspeedyAPIs.debug(()=>{
1186
- const webpackPluginPath = require.resolve('@lynx-js/react-webpack-plugin');
1187
- return `Using @lynx-js/react-webpack-plugin v${version} at ${webpackPluginPath}`;
1188
- });
1207
+ const webpackPluginPath = require.resolve('@lynx-js/react-webpack-plugin');
1208
+ api.logger?.debug(`Using @lynx-js/react-webpack-plugin v${version} at ${webpackPluginPath}`);
1189
1209
  }
1190
1210
  }
1191
1211
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-rsbuild-plugin-canary",
3
- "version": "0.12.6-canary-20260119-609be14f",
3
+ "version": "0.12.6-canary-20260119-51d6b269",
4
4
  "description": "A rsbuild plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "rsbuild",
@@ -33,11 +33,11 @@
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.12.6-canary-20260119-609be14f",
36
+ "@lynx-js/react-alias-rsbuild-plugin": "npm:@lynx-js/react-alias-rsbuild-plugin-canary@0.12.6-canary-20260119-51d6b269",
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.3",
39
39
  "@lynx-js/runtime-wrapper-webpack-plugin": "npm:@lynx-js/runtime-wrapper-webpack-plugin-canary@0.1.3",
40
- "@lynx-js/template-webpack-plugin": "npm:@lynx-js/template-webpack-plugin-canary@0.10.2-canary-20260119-609be14f",
40
+ "@lynx-js/template-webpack-plugin": "npm:@lynx-js/template-webpack-plugin-canary@0.10.2-canary-20260119-51d6b269",
41
41
  "@lynx-js/use-sync-external-store": "npm:@lynx-js/use-sync-external-store-canary@1.5.0",
42
42
  "background-only": "npm:background-only-canary@0.0.1"
43
43
  },
@@ -55,10 +55,10 @@
55
55
  "typia": "10.1.0",
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
- "@lynx-js/react": "npm:@lynx-js/react-canary@0.116.0-canary-20260119-609be14f",
58
+ "@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.13.1-canary-20260119-51d6b269",
59
59
  "@lynx-js/react-transform": "0.2.0",
60
- "@lynx-js/rspeedy": "npm:@lynx-js/rspeedy-canary@0.13.1-canary-20260119-609be14f",
61
- "@lynx-js/vitest-setup": "0.0.0"
60
+ "@lynx-js/vitest-setup": "0.0.0",
61
+ "@lynx-js/react": "npm:@lynx-js/react-canary@0.116.0-canary-20260119-51d6b269"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@lynx-js/react": "*"