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

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,35 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.6.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Support `@lynx-js/react` v0.106.0. ([#239](https://github.com/lynx-family/lynx-stack/pull/239))
8
+
9
+ ## 0.6.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Shake `useImperativeHandle` on the main-thread by default. ([#153](https://github.com/lynx-family/lynx-stack/pull/153))
14
+
15
+ ```js
16
+ import { forwardRef, useImperativeHandle } from '@lynx-js/react';
17
+
18
+ export default forwardRef(function App(_, ref) {
19
+ useImperativeHandle(ref, () => {
20
+ // This should be considered as background only
21
+ return {
22
+ name() {
23
+ // This should be considered as background only
24
+ console.info('This should not exist in main-thread');
25
+ },
26
+ };
27
+ });
28
+ });
29
+ ```
30
+
31
+ - Avoid wrapping standalone lazy bundles with `var globDynamicComponentEntry`. ([#177](https://github.com/lynx-family/lynx-stack/pull/177))
32
+
3
33
  ## 0.6.7
4
34
 
5
35
  ### Patch Changes
@@ -14,10 +14,20 @@ interface ReactWebpackPluginOptions {
14
14
  * {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.firstScreenSyncTiming}
15
15
  */
16
16
  firstScreenSyncTiming?: 'immediately' | 'jsReady';
17
+ /**
18
+ * {@inheritdoc @lynx-dev/react-rsbuild-plugin#PluginReactLynxOptions.enableSSR}
19
+ */
20
+ enableSSR?: boolean;
17
21
  /**
18
22
  * The chunk names to be considered as main thread chunks.
19
23
  */
20
24
  mainThreadChunks?: string[] | undefined;
25
+ /**
26
+ * Whether to enable lazy bundle.
27
+ *
28
+ * @alpha
29
+ */
30
+ experimental_isLazyBundle?: boolean;
21
31
  }
22
32
  /**
23
33
  * ReactWebpackPlugin allows using ReactLynx with webpack
@@ -73,7 +73,9 @@ class ReactWebpackPlugin {
73
73
  .freeze({
74
74
  disableCreateSelectorQueryIncompatibleWarning: false,
75
75
  firstScreenSyncTiming: 'immediately',
76
+ enableSSR: false,
76
77
  mainThreadChunks: [],
78
+ experimental_isLazyBundle: false,
77
79
  }); }
78
80
  /**
79
81
  * The entry point of a webpack plugin.
@@ -82,12 +84,14 @@ class ReactWebpackPlugin {
82
84
  apply(compiler) {
83
85
  const options = Object.assign({}, ReactWebpackPlugin.defaultOptions, this.options);
84
86
  const { BannerPlugin, DefinePlugin, EnvironmentPlugin } = compiler.webpack;
85
- new BannerPlugin({
86
- // TODO: handle cases that do not have `'use strict'`
87
- banner: `'use strict';var globDynamicComponentEntry=globDynamicComponentEntry||'__Card__';`,
88
- raw: true,
89
- test: options.mainThreadChunks,
90
- }).apply(compiler);
87
+ if (!options.experimental_isLazyBundle) {
88
+ new BannerPlugin({
89
+ // TODO: handle cases that do not have `'use strict'`
90
+ banner: `'use strict';var globDynamicComponentEntry=globDynamicComponentEntry||'__Card__';`,
91
+ raw: true,
92
+ test: options.mainThreadChunks,
93
+ }).apply(compiler);
94
+ }
91
95
  new EnvironmentPlugin({
92
96
  // Default values of null and undefined behave differently.
93
97
  // Use undefined for variables that must be provided during bundling, or null if they are optional.
@@ -102,6 +106,7 @@ class ReactWebpackPlugin {
102
106
  // TODO: config
103
107
  __EXTRACT_STR__: JSON.stringify(false),
104
108
  __FIRST_SCREEN_SYNC_TIMING__: JSON.stringify(options.firstScreenSyncTiming),
109
+ __ENABLE_SSR__: JSON.stringify(options.enableSSR),
105
110
  __DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__: JSON.stringify(options.disableCreateSelectorQueryIncompatibleWarning),
106
111
  }).apply(compiler);
107
112
  compiler.hooks.thisCompilation.tap(this.constructor.name, compilation => {
@@ -150,6 +150,7 @@ export function getMainThreadTransformOptions() {
150
150
  'useLayoutEffect',
151
151
  '__runInJS',
152
152
  'useLynxGlobalEventListener',
153
+ 'useImperativeHandle',
153
154
  ...(shake?.removeCallParams ?? []),
154
155
  ],
155
156
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-webpack-plugin",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -38,18 +38,18 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@microsoft/api-extractor": "7.51.1",
41
- "@rspack/core": "1.2.7",
41
+ "@rspack/core": "1.3.0-beta.0",
42
42
  "css-loader": "^7.1.2",
43
43
  "swc-loader": "^0.2.6",
44
44
  "webpack": "^5.98.0",
45
- "@lynx-js/css-extract-webpack-plugin": "0.5.1",
46
- "@lynx-js/react": "0.105.1",
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",
47
48
  "@lynx-js/test-tools": "0.0.0",
48
- "@lynx-js/template-webpack-plugin": "0.6.4",
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",
52
+ "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0",
53
53
  "@lynx-js/template-webpack-plugin": "^0.4.0 || ^0.5.0 || ^0.6.0"
54
54
  },
55
55
  "peerDependenciesMeta": {