@lynx-js/react-webpack-plugin 0.6.9 → 0.6.11

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,28 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.6.11
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: fully support MTS ([#569](https://github.com/lynx-family/lynx-stack/pull/569))
8
+
9
+ Now use support the following usage
10
+
11
+ - mainthread event
12
+ - mainthread ref
13
+ - runOnMainThread/runOnBackground
14
+ - ref.current.xx
15
+
16
+ ## 0.6.10
17
+
18
+ ### Patch Changes
19
+
20
+ - feat: add extractStr option to pluginReactLynx ([#391](https://github.com/lynx-family/lynx-stack/pull/391))
21
+
22
+ - Fix issue with lazy loading of bundles when source maps are enabled. ([#380](https://github.com/lynx-family/lynx-stack/pull/380))
23
+
24
+ - Fix issue where loading a lazy bundle fails if it does not return a webpack chunk. ([#365](https://github.com/lynx-family/lynx-stack/pull/365))
25
+
3
26
  ## 0.6.9
4
27
 
5
28
  ### Patch Changes
@@ -12,8 +12,8 @@ export function createLynxProcessEvalResultRuntimeModule(webpack) {
12
12
  }
13
13
  return `
14
14
  ${LynxRuntimeGlobals.lynxProcessEvalResult} = function (result, schema) {
15
- var chunk = result(schema);
16
- if (chunk.ids && chunk.modules) {
15
+ var chunk = result && result(schema);
16
+ if (chunk && chunk.ids && chunk.modules) {
17
17
  // We only deal with webpack chunk
18
18
  ${webpack.RuntimeGlobals.externalInstallChunk}(chunk);
19
19
  // TODO: sort with preOrderIndex. See: https://github.com/web-infra-dev/rspack/pull/8588
@@ -22,6 +22,7 @@ ${LynxRuntimeGlobals.lynxProcessEvalResult} = function (result, schema) {
22
22
  }
23
23
  return chunk;
24
24
  }
25
+ return chunk
25
26
  }
26
27
  `;
27
28
  }
@@ -1,5 +1,20 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  import { LAYERS } from './layer.js';
3
+ /**
4
+ * The options for extractStr.
5
+ *
6
+ * @public
7
+ */
8
+ export interface ExtractStrConfig {
9
+ /**
10
+ * The minimum length of string literals to be extracted.
11
+ *
12
+ * @defaultValue `20`
13
+ *
14
+ * @public
15
+ */
16
+ strLength: number;
17
+ }
3
18
  /**
4
19
  * The options for ReactWebpackPlugin
5
20
  *
@@ -15,13 +30,20 @@ interface ReactWebpackPluginOptions {
15
30
  */
16
31
  firstScreenSyncTiming?: 'immediately' | 'jsReady';
17
32
  /**
18
- * {@inheritdoc @lynx-dev/react-rsbuild-plugin#PluginReactLynxOptions.enableSSR}
33
+ * {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.enableSSR}
19
34
  */
20
35
  enableSSR?: boolean;
21
36
  /**
22
37
  * The chunk names to be considered as main thread chunks.
23
38
  */
24
39
  mainThreadChunks?: string[] | undefined;
40
+ /**
41
+ * Merge same string literals in JS and Lepus to reduce output bundle size.
42
+ * Set to `false` to disable.
43
+ *
44
+ * @defaultValue false
45
+ */
46
+ extractStr?: Partial<ExtractStrConfig> | boolean;
25
47
  /**
26
48
  * Whether to enable lazy bundle.
27
49
  *
@@ -75,6 +75,7 @@ class ReactWebpackPlugin {
75
75
  firstScreenSyncTiming: 'immediately',
76
76
  enableSSR: false,
77
77
  mainThreadChunks: [],
78
+ extractStr: false,
78
79
  experimental_isLazyBundle: false,
79
80
  }); }
80
81
  /**
@@ -95,7 +96,6 @@ class ReactWebpackPlugin {
95
96
  new EnvironmentPlugin({
96
97
  // Default values of null and undefined behave differently.
97
98
  // Use undefined for variables that must be provided during bundling, or null if they are optional.
98
- NODE_ENV: null,
99
99
  DEBUG: null,
100
100
  }).apply(compiler);
101
101
  new DefinePlugin({
@@ -103,8 +103,7 @@ class ReactWebpackPlugin {
103
103
  // We enable profile by default in development.
104
104
  // It can also be disabled by environment variable `REACT_PROFILE=false`
105
105
  __PROFILE__: JSON.stringify(process.env['REACT_PROFILE'] ?? compiler.options.mode === 'development'),
106
- // TODO: config
107
- __EXTRACT_STR__: JSON.stringify(false),
106
+ __EXTRACT_STR__: JSON.stringify(Boolean(options.extractStr)),
108
107
  __FIRST_SCREEN_SYNC_TIMING__: JSON.stringify(options.firstScreenSyncTiming),
109
108
  __ENABLE_SSR__: JSON.stringify(options.enableSSR),
110
109
  __DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__: JSON.stringify(options.disableCreateSelectorQueryIncompatibleWarning),
@@ -180,8 +179,8 @@ class ReactWebpackPlugin {
180
179
  (function (globDynamicComponentEntry) {
181
180
  const module = { exports: {} }
182
181
  const exports = module.exports
183
- `, old, `\
184
- return module.exports
182
+ `, old, `
183
+ ;return module.exports
185
184
  })`));
186
185
  return args;
187
186
  });
package/lib/index.d.ts CHANGED
@@ -4,6 +4,6 @@
4
4
  * A webpack plugin to integrate webpack with ReactLynx.
5
5
  */
6
6
  export { ReactWebpackPlugin } from './ReactWebpackPlugin.js';
7
- export type { ReactWebpackPluginOptions } from './ReactWebpackPlugin.js';
7
+ export type { ReactWebpackPluginOptions, ExtractStrConfig, } from './ReactWebpackPlugin.js';
8
8
  export { LAYERS } from './layer.js';
9
9
  export type { ReactLoaderOptions } from './loaders/options.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-webpack-plugin",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -37,14 +37,14 @@
37
37
  "@lynx-js/webpack-runtime-globals": "0.0.5"
38
38
  },
39
39
  "devDependencies": {
40
- "@microsoft/api-extractor": "7.51.1",
41
- "@rspack/core": "1.3.0-beta.0",
40
+ "@microsoft/api-extractor": "7.52.3",
41
+ "@rspack/core": "1.3.5",
42
42
  "css-loader": "^7.1.2",
43
43
  "swc-loader": "^0.2.6",
44
- "webpack": "^5.98.0",
45
- "@lynx-js/react": "0.106.0",
46
- "@lynx-js/css-extract-webpack-plugin": "0.5.2",
47
- "@lynx-js/template-webpack-plugin": "0.6.6",
44
+ "webpack": "^5.99.5",
45
+ "@lynx-js/css-extract-webpack-plugin": "0.5.3",
46
+ "@lynx-js/react": "0.106.5",
47
+ "@lynx-js/template-webpack-plugin": "0.6.9",
48
48
  "@lynx-js/test-tools": "0.0.0",
49
49
  "@lynx-js/vitest-setup": "0.0.0"
50
50
  },