@lynx-js/react-webpack-plugin-canary 0.15.2 → 0.15.3-canary-20261126-39d0f114

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,18 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.15.3-canary-20261126045827-39d0f11480245f9beb3583f1f4781d3cf7912eb4
4
+
5
+ ### Patch Changes
6
+
7
+ - Align Element Template runtime aliases and compiler-injected entry specifiers across `@lynx-js/react`, `@lynx-js/react-alias-rsbuild-plugin`, `@lynx-js/react-rsbuild-plugin`, and `@lynx-js/react-webpack-plugin`: ([#4419](https://github.com/lynx-family/lynx-stack/pull/4419))
8
+
9
+ - Export `./element-template/experimental/lazy/import` from `@lynx-js/react` (with fallback to `runtime/lazy/element-template-import.js` on older peers).
10
+ - Alias `@lynx-js/react/lepus$` and `@lynx-js/react/element-template/jsx-(dev-)runtime$` consistently across layers and read `lazy`/`elementTemplate` options lazily during `modifyBundlerChain`.
11
+ - Route Element Template `compat`, `worklet`, `dynamicImport`, `Defines`, and testing-loader `jsxImportSource` to explicit Element Template runtime entries.
12
+ - Updated dependencies [[`0bc72b7`](https://github.com/lynx-family/lynx-stack/commit/0bc72b732eb417d747010b48193d51736ffbae8f), [`22e9f56`](https://github.com/lynx-family/lynx-stack/commit/22e9f56c65b0c106c79f87072391ec341f4718cb), [`13b405d`](https://github.com/lynx-family/lynx-stack/commit/13b405d9ff13d01171879f55d9a757ae99dcee56), [`ba674aa`](https://github.com/lynx-family/lynx-stack/commit/ba674aa5e08ad1a884930c9f873c226ff5f1649c), [`ba674aa`](https://github.com/lynx-family/lynx-stack/commit/ba674aa5e08ad1a884930c9f873c226ff5f1649c), [`0e64e4e`](https://github.com/lynx-family/lynx-stack/commit/0e64e4e9cac2432fe16573379c198f1bc495651b)]:
13
+ - @lynx-js/react@0.129.5-canary-20261126045827-39d0f11480245f9beb3583f1f4781d3cf7912eb4
14
+ - @lynx-js/template-webpack-plugin@0.16.10-canary-20261126045827-39d0f11480245f9beb3583f1f4781d3cf7912eb4
15
+
3
16
  ## 0.15.2
4
17
 
5
18
  ### Patch Changes
package/lib/Defines.d.ts CHANGED
@@ -17,4 +17,4 @@ export interface Define {
17
17
  export declare function collectDefines<TModule>(modules: Iterable<TModule>, buildInfoKey: string, getModuleIdentifier: (module: TModule) => string): Define[];
18
18
  export declare function selectMissingDefines(candidates: readonly Define[], present: readonly Define[]): Define[];
19
19
  export declare function renderDefines(defines: readonly Define[]): string;
20
- export declare function renderDefinesModule(definesForSnapshot: readonly Define[], definesForWorklet: readonly Define[]): string;
20
+ export declare function renderDefinesModule(definesForSnapshot: readonly Define[], definesForWorklet: readonly Define[], runtimePkg?: string): string;
package/lib/Defines.js CHANGED
@@ -60,8 +60,8 @@ export function renderDefines(defines) {
60
60
  .map(({ id, code }) => `// ${id}\n{\n${code}\n}`)
61
61
  .join('\n');
62
62
  }
63
- export function renderDefinesModule(definesForSnapshot, definesForWorklet) {
64
- const prelude = [`import * as ReactLynx from '@lynx-js/react/internal';`];
63
+ export function renderDefinesModule(definesForSnapshot, definesForWorklet, runtimePkg = '@lynx-js/react/internal') {
64
+ const prelude = [`import * as ReactLynx from '${runtimePkg}';`];
65
65
  const defines = [...definesForWorklet, ...definesForSnapshot];
66
66
  const locals = new Set(defines.flatMap(define => define.imports?.map(({ local }) => local) ?? []));
67
67
  const imports = new Map();
@@ -3,4 +3,4 @@ export interface EntryPair {
3
3
  mainThread: string;
4
4
  background: string;
5
5
  }
6
- export declare function applyDefinesInjection(compiler: Compiler, entryPairs: EntryPair[], pluginName: string): void;
6
+ export declare function applyDefinesInjection(compiler: Compiler, entryPairs: EntryPair[], pluginName: string, runtimePkg?: string): void;
@@ -7,7 +7,7 @@ import { MAIN_THREAD_HMR } from './hmr/enabled.js';
7
7
  import { LAYERS } from './layer.js';
8
8
  import { boundaryKey, definesImportByBoundary, } from './loaders/defines-import-by-boundary.js';
9
9
  import { REACT_RUNTIME_REQUIREMENTS_BUILD_INFO, } from './loaders/main-thread.js';
10
- export function applyDefinesInjection(compiler, entryPairs, pluginName) {
10
+ export function applyDefinesInjection(compiler, entryPairs, pluginName, runtimePkg) {
11
11
  const { EntryPlugin, experiments } = compiler.webpack;
12
12
  const virtualModules = new experiments.VirtualModulesPlugin({});
13
13
  virtualModules.apply(compiler);
@@ -100,7 +100,7 @@ export function applyDefinesInjection(compiler, entryPairs, pluginName) {
100
100
  }
101
101
  if (keepEmpty || missingSnapshot.length > 0 || missingWorklet.length > 0) {
102
102
  const previousModule = [...compilation.modules].find(module => module.resource === request);
103
- virtualModules.writeModule(request, renderDefinesModule(missingSnapshot, missingWorklet)
103
+ virtualModules.writeModule(request, renderDefinesModule(missingSnapshot, missingWorklet, runtimePkg)
104
104
  + (compiler[MAIN_THREAD_HMR]
105
105
  ? '\nif (module.hot) module.hot.accept();'
106
106
  : ''));
@@ -9,6 +9,7 @@ import { applyDefinesInjection } from './DefinesInjection.js';
9
9
  import { MAIN_THREAD_HMR } from './hmr/enabled.js';
10
10
  import { LAYERS } from './layer.js';
11
11
  import { ELEMENT_TEMPLATE_BUILD_INFO, REACT_RUNTIME_REQUIREMENTS_BUILD_INFO, } from './loaders/main-thread.js';
12
+ import { ELEMENT_TEMPLATE_INTERNAL_PKG, RUNTIME_PKG, } from './loaders/options.js';
12
13
  import { createLynxProcessEvalResultRuntimeModule } from './LynxProcessEvalResultRuntimeModule.js';
13
14
  import { applyMainThreadHMR } from './MainThreadHMR.js';
14
15
  const require = createRequire(import.meta.url);
@@ -310,7 +311,9 @@ class ReactWebpackPlugin {
310
311
  }).apply(compiler);
311
312
  const entryPairs = options.entryPairs ?? [];
312
313
  if (entryPairs.length > 0) {
313
- applyDefinesInjection(compiler, entryPairs, this.constructor.name);
314
+ applyDefinesInjection(compiler, entryPairs, this.constructor.name, options.experimental_useElementTemplate
315
+ ? ELEMENT_TEMPLATE_INTERNAL_PKG
316
+ : RUNTIME_PKG);
314
317
  if (isDev && !options.experimental_isLazyBundle
315
318
  && compiler.options.plugins.some(plugin => plugin instanceof compiler.webpack.HotModuleReplacementPlugin)
316
319
  && compiler.options.plugins.some(plugin => plugin instanceof LynxEncodePlugin)) {
@@ -7,6 +7,7 @@ export declare const JSX_IMPORT_SOURCE: {
7
7
  };
8
8
  export declare const RUNTIME_PKG = "@lynx-js/react/internal";
9
9
  export declare const ELEMENT_TEMPLATE_RUNTIME_PKG = "@lynx-js/react/element-template";
10
+ export declare const ELEMENT_TEMPLATE_INTERNAL_PKG = "@lynx-js/react/element-template/internal";
10
11
  /**
11
12
  * The options of the ReactLynx plugin.
12
13
  * @public
@@ -11,6 +11,7 @@ export const JSX_IMPORT_SOURCE = {
11
11
  const PUBLIC_RUNTIME_PKG = '@lynx-js/react';
12
12
  export const RUNTIME_PKG = '@lynx-js/react/internal';
13
13
  export const ELEMENT_TEMPLATE_RUNTIME_PKG = '@lynx-js/react/element-template';
14
+ export const ELEMENT_TEMPLATE_INTERNAL_PKG = '@lynx-js/react/element-template/internal';
14
15
  const OLD_RUNTIME_PKG = '@lynx-js/react-runtime';
15
16
  const COMPONENT_PKG = '@lynx-js/react-components';
16
17
  function normalizeSlashes(file) {
@@ -104,7 +105,9 @@ function getCommonOptions(inputSourceMap) {
104
105
  // TODO: config
105
106
  worklet: {
106
107
  filename: filename,
107
- runtimePkg: RUNTIME_PKG,
108
+ runtimePkg: useElementTemplate
109
+ ? ELEMENT_TEMPLATE_INTERNAL_PKG
110
+ : RUNTIME_PKG,
108
111
  target: 'MIXED',
109
112
  },
110
113
  directiveDCE: false,
@@ -143,7 +146,9 @@ export function getMainThreadTransformOptions(inputSourceMap) {
143
146
  : false,
144
147
  dynamicImport: {
145
148
  layer: `react__main-thread`,
146
- runtimePkg: RUNTIME_PKG,
149
+ runtimePkg: useElementTemplate
150
+ ? ELEMENT_TEMPLATE_INTERNAL_PKG
151
+ : RUNTIME_PKG,
147
152
  },
148
153
  defineDCE: {
149
154
  define: {
@@ -219,7 +224,9 @@ export function getBackgroundTransformOptions(inputSourceMap) {
219
224
  : false,
220
225
  dynamicImport: {
221
226
  layer: `react__background`,
222
- runtimePkg: RUNTIME_PKG,
227
+ runtimePkg: useElementTemplate
228
+ ? ELEMENT_TEMPLATE_INTERNAL_PKG
229
+ : RUNTIME_PKG,
223
230
  },
224
231
  snapshot: useElementTemplate ? false : {
225
232
  ...commonOptions.snapshot,
@@ -3,7 +3,7 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { createRequire } from 'node:module';
5
5
  import path from 'node:path';
6
- import { ELEMENT_TEMPLATE_RUNTIME_PKG, JSX_IMPORT_SOURCE, RUNTIME_PKG, } from './options.js';
6
+ import { ELEMENT_TEMPLATE_INTERNAL_PKG, ELEMENT_TEMPLATE_RUNTIME_PKG, JSX_IMPORT_SOURCE, RUNTIME_PKG, } from './options.js';
7
7
  function normalizeSlashes(file) {
8
8
  return file.replaceAll(path.win32.sep, '/');
9
9
  }
@@ -45,7 +45,9 @@ function testingLoader(content) {
45
45
  ? {
46
46
  preserveJsx: false,
47
47
  runtimePkg: ELEMENT_TEMPLATE_RUNTIME_PKG,
48
- jsxImportSource: JSX_IMPORT_SOURCE.ELEMENT_TEMPLATE,
48
+ // MIXED mode runs in a no-layer test environment; keep standard Preact
49
+ // JSX so background diffing preserves keys and VNode metadata.
50
+ jsxImportSource: JSX_IMPORT_SOURCE.BACKGROUND,
49
51
  filename,
50
52
  target: 'MIXED',
51
53
  }
@@ -58,7 +60,9 @@ function testingLoader(content) {
58
60
  engineVersion,
59
61
  worklet: {
60
62
  filename,
61
- runtimePkg: RUNTIME_PKG,
63
+ runtimePkg: experimental_useElementTemplate
64
+ ? ELEMENT_TEMPLATE_INTERNAL_PKG
65
+ : RUNTIME_PKG,
62
66
  target: 'MIXED',
63
67
  },
64
68
  refresh: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-webpack-plugin-canary",
3
- "version": "0.15.2",
3
+ "version": "0.15.3-canary-20261126-39d0f114",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -40,11 +40,11 @@
40
40
  "devDependencies": {
41
41
  "@lynx-js/chunk-loading-webpack-plugin": "npm:@lynx-js/chunk-loading-webpack-plugin-canary@0.4.3",
42
42
  "@lynx-js/css-extract-webpack-plugin": "npm:@lynx-js/css-extract-webpack-plugin-canary@0.11.2",
43
- "@lynx-js/react": "npm:@lynx-js/react-canary@0.129.4",
44
- "@lynx-js/template-webpack-plugin": "npm:@lynx-js/template-webpack-plugin-canary@0.16.9",
43
+ "@lynx-js/react": "npm:@lynx-js/react-canary@0.129.5-canary-20261126-39d0f114",
44
+ "@lynx-js/template-webpack-plugin": "npm:@lynx-js/template-webpack-plugin-canary@0.16.10-canary-20261126-39d0f114",
45
45
  "@lynx-js/test-tools": "0.0.0",
46
46
  "@microsoft/api-extractor": "7.59.4",
47
- "@rspack/core": "2.3.3",
47
+ "@rspack/core": "2.3.4",
48
48
  "@rspack/lite-tapable": "1.3.0",
49
49
  "@rstest/core": "0.12.6",
50
50
  "css-loader": "^7.1.4",