@lynx-js/react-webpack-plugin 0.6.15 → 0.6.17

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,49 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.6.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Enable fine-grained control for `output.inlineScripts` ([#883](https://github.com/lynx-family/lynx-stack/pull/883))
8
+
9
+ ```ts
10
+ type InlineChunkTestFunction = (params: {
11
+ size: number;
12
+ name: string;
13
+ }) => boolean;
14
+
15
+ type InlineChunkTest = RegExp | InlineChunkTestFunction;
16
+
17
+ type InlineChunkConfig =
18
+ | boolean
19
+ | InlineChunkTest
20
+ | { enable?: boolean | 'auto'; test: InlineChunkTest };
21
+ ```
22
+
23
+ ```ts
24
+ import { defineConfig } from '@lynx-js/rspeedy';
25
+
26
+ export default defineConfig({
27
+ output: {
28
+ inlineScripts: ({ name, size }) => {
29
+ return name.includes('foo') && size < 1000;
30
+ },
31
+ },
32
+ });
33
+ ```
34
+
35
+ ## 0.6.16
36
+
37
+ ### Patch Changes
38
+
39
+ - Supports `@lynx-js/template-webpack-plugin` 0.8.0. ([#1033](https://github.com/lynx-family/lynx-stack/pull/1033))
40
+
41
+ - Support `@lynx-js/react` v0.110.0. ([#770](https://github.com/lynx-family/lynx-stack/pull/770))
42
+
43
+ - Keep snapshot id unchanged on Windows. ([#1050](https://github.com/lynx-family/lynx-stack/pull/1050))
44
+
45
+ - Fix lazy bundle name on Windows. ([#1060](https://github.com/lynx-family/lynx-stack/pull/1060))
46
+
3
47
  ## 0.6.15
4
48
 
5
49
  ### Patch Changes
@@ -159,6 +159,7 @@ class ReactWebpackPlugin {
159
159
  const runtimeFile = require.resolve(path);
160
160
  lepusCode.chunks.push({
161
161
  name: 'worklet-runtime',
162
+ // @ts-expect-error Rspack x Webpack sources not match
162
163
  source: new RawSource(fs.readFileSync(runtimeFile, 'utf8')),
163
164
  info: {
164
165
  ['lynx:main-thread']: true,
@@ -187,11 +188,11 @@ class ReactWebpackPlugin {
187
188
  })`));
188
189
  return args;
189
190
  });
190
- // The react-transform will add `-${LAYER}` to the webpackChunkName.
191
+ // The react-transform will add `-react__${LAYER}` to the webpackChunkName.
191
192
  // We replace it with an empty string here to make sure main-thread & background chunk match.
192
193
  hooks.asyncChunkName.tap(this.constructor.name, (chunkName) => chunkName
193
- ?.replaceAll(`-${LAYERS.BACKGROUND}`, '')
194
- ?.replaceAll(`-${LAYERS.MAIN_THREAD}`, ''));
194
+ ?.replaceAll(`-react__background`, '')
195
+ ?.replaceAll(`-react__main-thread`, ''));
195
196
  });
196
197
  }
197
198
  #updateMainThreadInfo(compilation, name) {
@@ -2,7 +2,6 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import path from 'node:path';
5
- import { LAYERS } from '../layer.js';
6
5
  const PLUGIN_NAME = 'react:webpack';
7
6
  const JSX_IMPORT_SOURCE = {
8
7
  MAIN_THREAD: '@lynx-js/react/lepus',
@@ -12,8 +11,11 @@ const PUBLIC_RUNTIME_PKG = '@lynx-js/react';
12
11
  const RUNTIME_PKG = '@lynx-js/react/internal';
13
12
  const OLD_RUNTIME_PKG = '@lynx-js/react-runtime';
14
13
  const COMPONENT_PKG = '@lynx-js/react-components';
14
+ function normalizeSlashes(file) {
15
+ return file.replaceAll(path.win32.sep, '/');
16
+ }
15
17
  function getCommonOptions() {
16
- const filename = path.relative(this.rootContext, this.resourcePath);
18
+ const filename = normalizeSlashes(path.relative(this.rootContext, this.resourcePath));
17
19
  const { compat, enableRemoveCSSScope, inlineSourcesContent, isDynamicComponent, defineDCE = { define: {} }, } = this.getOptions();
18
20
  const syntax = (/\.[mc]?tsx?$/.exec(this.resourcePath))
19
21
  ? 'typescript'
@@ -109,7 +111,7 @@ export function getMainThreadTransformOptions() {
109
111
  target: 'LEPUS',
110
112
  },
111
113
  dynamicImport: {
112
- layer: LAYERS.MAIN_THREAD,
114
+ layer: `react__main-thread`,
113
115
  runtimePkg: RUNTIME_PKG,
114
116
  },
115
117
  defineDCE: {
@@ -179,7 +181,7 @@ export function getBackgroundTransformOptions() {
179
181
  }
180
182
  : false,
181
183
  dynamicImport: {
182
- layer: LAYERS.BACKGROUND,
184
+ layer: `react__background`,
183
185
  runtimePkg: RUNTIME_PKG,
184
186
  },
185
187
  snapshot: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-webpack-plugin",
3
- "version": "0.6.15",
3
+ "version": "0.6.17",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -38,19 +38,19 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@microsoft/api-extractor": "7.52.8",
41
- "@rspack/core": "1.3.11",
41
+ "@rspack/core": "1.4.0-rc.0",
42
42
  "css-loader": "^7.1.2",
43
43
  "swc-loader": "^0.2.6",
44
44
  "webpack": "^5.99.9",
45
- "@lynx-js/css-extract-webpack-plugin": "0.5.4",
46
- "@lynx-js/react": "0.109.1",
47
- "@lynx-js/template-webpack-plugin": "0.7.1",
45
+ "@lynx-js/css-extract-webpack-plugin": "0.6.0",
46
+ "@lynx-js/react": "0.110.1",
47
+ "@lynx-js/template-webpack-plugin": "0.8.1",
48
48
  "@lynx-js/test-tools": "0.0.0",
49
49
  "@lynx-js/vitest-setup": "0.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0",
53
- "@lynx-js/template-webpack-plugin": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0"
52
+ "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0",
53
+ "@lynx-js/template-webpack-plugin": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@lynx-js/react": {