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

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,15 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.6.10
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add extractStr option to pluginReactLynx ([#391](https://github.com/lynx-family/lynx-stack/pull/391))
8
+
9
+ - Fix issue with lazy loading of bundles when source maps are enabled. ([#380](https://github.com/lynx-family/lynx-stack/pull/380))
10
+
11
+ - 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))
12
+
3
13
  ## 0.6.9
4
14
 
5
15
  ### 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
  *
@@ -22,6 +37,13 @@ interface ReactWebpackPluginOptions {
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
  /**
@@ -103,8 +104,7 @@ class ReactWebpackPlugin {
103
104
  // We enable profile by default in development.
104
105
  // It can also be disabled by environment variable `REACT_PROFILE=false`
105
106
  __PROFILE__: JSON.stringify(process.env['REACT_PROFILE'] ?? compiler.options.mode === 'development'),
106
- // TODO: config
107
- __EXTRACT_STR__: JSON.stringify(false),
107
+ __EXTRACT_STR__: JSON.stringify(Boolean(options.extractStr)),
108
108
  __FIRST_SCREEN_SYNC_TIMING__: JSON.stringify(options.firstScreenSyncTiming),
109
109
  __ENABLE_SSR__: JSON.stringify(options.enableSSR),
110
110
  __DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__: JSON.stringify(options.disableCreateSelectorQueryIncompatibleWarning),
@@ -180,8 +180,8 @@ class ReactWebpackPlugin {
180
180
  (function (globDynamicComponentEntry) {
181
181
  const module = { exports: {} }
182
182
  const exports = module.exports
183
- `, old, `\
184
- return module.exports
183
+ `, old, `
184
+ ;return module.exports
185
185
  })`));
186
186
  return args;
187
187
  });
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.10",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@microsoft/api-extractor": "7.51.1",
41
- "@rspack/core": "1.3.0-beta.0",
41
+ "@rspack/core": "1.3.0-beta.1",
42
42
  "css-loader": "^7.1.2",
43
43
  "swc-loader": "^0.2.6",
44
44
  "webpack": "^5.98.0",
45
- "@lynx-js/react": "0.106.0",
46
45
  "@lynx-js/css-extract-webpack-plugin": "0.5.2",
47
- "@lynx-js/template-webpack-plugin": "0.6.6",
46
+ "@lynx-js/react": "0.106.2",
47
+ "@lynx-js/template-webpack-plugin": "0.6.7",
48
48
  "@lynx-js/test-tools": "0.0.0",
49
49
  "@lynx-js/vitest-setup": "0.0.0"
50
50
  },