@lynx-js/runtime-wrapper-webpack-plugin 0.0.9 → 0.1.0
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,19 @@
|
|
|
1
1
|
# @lynx-js/runtime-wrapper-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add parameter forwarding for Browser Object Model (BOM) APIs. ([#787](https://github.com/lynx-family/lynx-stack/pull/787))
|
|
8
|
+
|
|
9
|
+
This allows direct access to APIs like `fetch`, `requestAnimationFrame`.
|
|
10
|
+
|
|
11
|
+
## 0.0.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- feat: add `experimental_isLazyBundle` option, it will disable lynxChunkEntries for standalone lazy bundle ([#653](https://github.com/lynx-family/lynx-stack/pull/653))
|
|
16
|
+
|
|
3
17
|
## 0.0.9
|
|
4
18
|
|
|
5
19
|
### 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,7 +17,31 @@ const defaultInjectVars = [
|
|
|
17
17
|
'Behavior',
|
|
18
18
|
'LynxJSBI',
|
|
19
19
|
'lynx',
|
|
20
|
+
// BOM API
|
|
20
21
|
'window',
|
|
22
|
+
'document',
|
|
23
|
+
'frames',
|
|
24
|
+
'self',
|
|
25
|
+
'location',
|
|
26
|
+
'navigator',
|
|
27
|
+
'localStorage',
|
|
28
|
+
'history',
|
|
29
|
+
'Caches',
|
|
30
|
+
'screen',
|
|
31
|
+
'alert',
|
|
32
|
+
'confirm',
|
|
33
|
+
'prompt',
|
|
34
|
+
'fetch',
|
|
35
|
+
'XMLHttpRequest',
|
|
36
|
+
'__WebSocket__', // We would provide `WebSocket` using `ProvidePlugin`
|
|
37
|
+
'webkit',
|
|
38
|
+
'Reporter',
|
|
39
|
+
'print',
|
|
40
|
+
'__Function__', // We should allow using `Function`
|
|
41
|
+
'global',
|
|
42
|
+
// Lynx API
|
|
43
|
+
'requestAnimationFrame',
|
|
44
|
+
'cancelAnimationFrame',
|
|
21
45
|
];
|
|
22
46
|
/**
|
|
23
47
|
* RuntimeWrapperWebpackPlugin adds runtime wrappers to JavaScript and allow to be loaded by Lynx.
|
|
@@ -39,6 +63,7 @@ class RuntimeWrapperWebpackPlugin {
|
|
|
39
63
|
test: /\.js$/,
|
|
40
64
|
bannerType: () => 'script',
|
|
41
65
|
injectVars: defaultInjectVars,
|
|
66
|
+
experimental_isLazyBundle: false,
|
|
42
67
|
});
|
|
43
68
|
/**
|
|
44
69
|
* The entry point of a webpack plugin.
|
|
@@ -57,7 +82,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
57
82
|
constructor(compiler, options) {
|
|
58
83
|
this.compiler = compiler;
|
|
59
84
|
this.options = options;
|
|
60
|
-
const { targetSdkVersion, test } = options;
|
|
85
|
+
const { targetSdkVersion, test, experimental_isLazyBundle } = options;
|
|
61
86
|
const { BannerPlugin } = compiler.webpack;
|
|
62
87
|
const isDev = process.env['NODE_ENV'] === 'development'
|
|
63
88
|
|| compiler.options.mode === 'development';
|
|
@@ -81,7 +106,12 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
81
106
|
moduleId: '[name].js',
|
|
82
107
|
targetSdkVersion,
|
|
83
108
|
})
|
|
84
|
-
|
|
109
|
+
// In standalone lazy bundle mode, the lazy bundle will
|
|
110
|
+
// also has chunk.id "main", it will be conflict with the
|
|
111
|
+
// consumer project.
|
|
112
|
+
// We disable it for standalone lazy bundle since we do not
|
|
113
|
+
// support HMR for standalone lazy bundle now.
|
|
114
|
+
+ (isDev && !experimental_isLazyBundle
|
|
85
115
|
? lynxChunkEntries(JSON.stringify(chunk.id))
|
|
86
116
|
: '');
|
|
87
117
|
},
|
|
@@ -150,7 +180,9 @@ const amdBanner = ({ injectStr, moduleId, overrideRuntimePromise, targetSdkVersi
|
|
|
150
180
|
lynx = lynx || {};
|
|
151
181
|
lynx.targetSdkVersion=lynx.targetSdkVersion||${JSON.stringify(targetSdkVersion)};
|
|
152
182
|
${overrideRuntimePromise ? `var Promise = lynx.Promise;` : ''}
|
|
153
|
-
|
|
183
|
+
fetch = fetch || lynx.fetch;
|
|
184
|
+
requestAnimationFrame = requestAnimationFrame || lynx.requestAnimationFrame;
|
|
185
|
+
cancelAnimationFrame = cancelAnimationFrame || lynx.cancelAnimationFrame;
|
|
154
186
|
`);
|
|
155
187
|
};
|
|
156
188
|
const amdFooter = (moduleId) => `
|
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.1.0",
|
|
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.8",
|
|
39
|
+
"webpack": "^5.99.8",
|
|
40
40
|
"@lynx-js/test-tools": "0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|