@lynx-js/runtime-wrapper-webpack-plugin 0.0.8 → 0.0.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,23 @@
|
|
|
1
1
|
# @lynx-js/runtime-wrapper-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add `experimental_isLazyBundle` option, it will disable lynxChunkEntries for standalone lazy bundle ([#653](https://github.com/lynx-family/lynx-stack/pull/653))
|
|
8
|
+
|
|
9
|
+
## 0.0.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Add `window` variable to callback argument in `background.js` and the `window` is `undefined` in Lynx. Sometimes it's useful to distinguish between Lynx and the Web. ([#248](https://github.com/lynx-family/lynx-stack/pull/248))
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
define('background.js', (..., window) => {
|
|
17
|
+
console.log(window); // `undefined` in Lynx
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
3
21
|
## 0.0.8
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ import type { BannerPlugin, Compiler } from 'webpack';
|
|
|
6
6
|
*/
|
|
7
7
|
interface RuntimeWrapperWebpackPluginOptions {
|
|
8
8
|
/**
|
|
9
|
-
* {@inheritdoc @lynx-js/
|
|
9
|
+
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.targetSdkVersion}
|
|
10
10
|
*/
|
|
11
11
|
targetSdkVersion: string;
|
|
12
12
|
/**
|
|
@@ -29,6 +29,10 @@ interface RuntimeWrapperWebpackPluginOptions {
|
|
|
29
29
|
* The variables to be injected into the chunk.
|
|
30
30
|
*/
|
|
31
31
|
injectVars?: ((vars: string[]) => string[]) | string[];
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.experimental_isLazyBundle}
|
|
34
|
+
*/
|
|
35
|
+
experimental_isLazyBundle?: boolean;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* RuntimeWrapperWebpackPlugin adds runtime wrappers to JavaScript and allow to be loaded by Lynx.
|
|
@@ -17,6 +17,7 @@ const defaultInjectVars = [
|
|
|
17
17
|
'Behavior',
|
|
18
18
|
'LynxJSBI',
|
|
19
19
|
'lynx',
|
|
20
|
+
'window',
|
|
20
21
|
];
|
|
21
22
|
/**
|
|
22
23
|
* RuntimeWrapperWebpackPlugin adds runtime wrappers to JavaScript and allow to be loaded by Lynx.
|
|
@@ -38,6 +39,7 @@ class RuntimeWrapperWebpackPlugin {
|
|
|
38
39
|
test: /\.js$/,
|
|
39
40
|
bannerType: () => 'script',
|
|
40
41
|
injectVars: defaultInjectVars,
|
|
42
|
+
experimental_isLazyBundle: false,
|
|
41
43
|
});
|
|
42
44
|
/**
|
|
43
45
|
* The entry point of a webpack plugin.
|
|
@@ -56,7 +58,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
56
58
|
constructor(compiler, options) {
|
|
57
59
|
this.compiler = compiler;
|
|
58
60
|
this.options = options;
|
|
59
|
-
const { targetSdkVersion, test } = options;
|
|
61
|
+
const { targetSdkVersion, test, experimental_isLazyBundle } = options;
|
|
60
62
|
const { BannerPlugin } = compiler.webpack;
|
|
61
63
|
const isDev = process.env['NODE_ENV'] === 'development'
|
|
62
64
|
|| compiler.options.mode === 'development';
|
|
@@ -80,7 +82,12 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
80
82
|
moduleId: '[name].js',
|
|
81
83
|
targetSdkVersion,
|
|
82
84
|
})
|
|
83
|
-
|
|
85
|
+
// In standalone lazy bundle mode, the lazy bundle will
|
|
86
|
+
// also has chunk.id "main", it will be conflict with the
|
|
87
|
+
// consumer project.
|
|
88
|
+
// We disable it for standalone lazy bundle since we do not
|
|
89
|
+
// support HMR for standalone lazy bundle now.
|
|
90
|
+
+ (isDev && !experimental_isLazyBundle
|
|
84
91
|
? lynxChunkEntries(JSON.stringify(chunk.id))
|
|
85
92
|
: '');
|
|
86
93
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/runtime-wrapper-webpack-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Use runtime wrapper which allow JavaScript to be load by Lynx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@lynx-js/webpack-runtime-globals": "0.0.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@microsoft/api-extractor": "7.
|
|
39
|
-
"webpack": "^5.
|
|
38
|
+
"@microsoft/api-extractor": "7.52.7",
|
|
39
|
+
"webpack": "^5.99.8",
|
|
40
40
|
"@lynx-js/test-tools": "0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|