@lynx-js/runtime-wrapper-webpack-plugin 0.1.0 → 0.1.2
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 +12 -0
- package/lib/RuntimeWrapperWebpackPlugin.js +10 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @lynx-js/runtime-wrapper-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Wrap with IIFE when `output.iife: false` to avoid naming conflict. ([#1176](https://github.com/lynx-family/lynx-stack/pull/1176))
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix `requestAnimationFrame` is not working. ([#1021](https://github.com/lynx-family/lynx-stack/pull/1021))
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -37,7 +37,6 @@ const defaultInjectVars = [
|
|
|
37
37
|
'webkit',
|
|
38
38
|
'Reporter',
|
|
39
39
|
'print',
|
|
40
|
-
'__Function__', // We should allow using `Function`
|
|
41
40
|
'global',
|
|
42
41
|
// Lynx API
|
|
43
42
|
'requestAnimationFrame',
|
|
@@ -90,6 +89,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
90
89
|
if (typeof options.injectVars === 'function') {
|
|
91
90
|
injectStr = options.injectVars(defaultInjectVars).join(',');
|
|
92
91
|
}
|
|
92
|
+
const iife = compiler.options.output.iife ?? true;
|
|
93
93
|
// banner
|
|
94
94
|
new BannerPlugin({
|
|
95
95
|
test: test,
|
|
@@ -105,6 +105,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
105
105
|
overrideRuntimePromise: true,
|
|
106
106
|
moduleId: '[name].js',
|
|
107
107
|
targetSdkVersion,
|
|
108
|
+
iife,
|
|
108
109
|
})
|
|
109
110
|
// In standalone lazy bundle mode, the lazy bundle will
|
|
110
111
|
// also has chunk.id "main", it will be conflict with the
|
|
@@ -125,7 +126,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
125
126
|
const footer = this.#getBannerType(filename) === 'script'
|
|
126
127
|
? loadScriptFooter
|
|
127
128
|
: loadBundleFooter;
|
|
128
|
-
return amdFooter('[name].js') + footer;
|
|
129
|
+
return amdFooter('[name].js', iife) + footer;
|
|
129
130
|
},
|
|
130
131
|
}).apply(compiler);
|
|
131
132
|
}
|
|
@@ -174,7 +175,10 @@ const loadBundleBanner = (strictMode = true) => `(function(){
|
|
|
174
175
|
function initBundle(lynxCoreInject) {
|
|
175
176
|
var tt = lynxCoreInject.tt;
|
|
176
177
|
`;
|
|
177
|
-
const amdBanner = ({ injectStr, moduleId, overrideRuntimePromise, targetSdkVersion, }) => {
|
|
178
|
+
const amdBanner = ({ injectStr, moduleId, overrideRuntimePromise, targetSdkVersion, iife, }) => {
|
|
179
|
+
const iifeWrapper = iife ? '' : `
|
|
180
|
+
// This needs to be wrapped in an IIFE because it needs to be isolated against Lynx injected variables.
|
|
181
|
+
(() => {`;
|
|
178
182
|
return (`
|
|
179
183
|
tt.define("${moduleId}", function(require, module, exports, ${injectStr}) {
|
|
180
184
|
lynx = lynx || {};
|
|
@@ -183,9 +187,11 @@ ${overrideRuntimePromise ? `var Promise = lynx.Promise;` : ''}
|
|
|
183
187
|
fetch = fetch || lynx.fetch;
|
|
184
188
|
requestAnimationFrame = requestAnimationFrame || lynx.requestAnimationFrame;
|
|
185
189
|
cancelAnimationFrame = cancelAnimationFrame || lynx.cancelAnimationFrame;
|
|
190
|
+
${iifeWrapper}
|
|
186
191
|
`);
|
|
187
192
|
};
|
|
188
|
-
const amdFooter = (moduleId) => `
|
|
193
|
+
const amdFooter = (moduleId, iife) => `
|
|
194
|
+
${iife ? '' : '})();'}
|
|
189
195
|
});
|
|
190
196
|
return tt.require("${moduleId}");`;
|
|
191
197
|
// footer for app-service.js chunk
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/runtime-wrapper-webpack-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Use runtime wrapper which allow JavaScript to be load by Lynx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@microsoft/api-extractor": "7.52.8",
|
|
39
|
-
"webpack": "^5.99.
|
|
39
|
+
"webpack": "^5.99.9",
|
|
40
40
|
"@lynx-js/test-tools": "0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|