@lynx-js/runtime-wrapper-webpack-plugin 0.1.1 → 0.1.3
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 +13 -0
- package/lib/RuntimeWrapperWebpackPlugin.js +10 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @lynx-js/runtime-wrapper-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`aaca8f9`](https://github.com/lynx-family/lynx-stack/commit/aaca8f91d177061c7b0430cc5cb21a3602897534)]:
|
|
8
|
+
- @lynx-js/webpack-runtime-globals@0.0.6
|
|
9
|
+
|
|
10
|
+
## 0.1.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Wrap with IIFE when `output.iife: false` to avoid naming conflict. ([#1176](https://github.com/lynx-family/lynx-stack/pull/1176))
|
|
15
|
+
|
|
3
16
|
## 0.1.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -89,6 +89,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
89
89
|
if (typeof options.injectVars === 'function') {
|
|
90
90
|
injectStr = options.injectVars(defaultInjectVars).join(',');
|
|
91
91
|
}
|
|
92
|
+
const iife = compiler.options.output.iife ?? true;
|
|
92
93
|
// banner
|
|
93
94
|
new BannerPlugin({
|
|
94
95
|
test: test,
|
|
@@ -104,6 +105,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
104
105
|
overrideRuntimePromise: true,
|
|
105
106
|
moduleId: '[name].js',
|
|
106
107
|
targetSdkVersion,
|
|
108
|
+
iife,
|
|
107
109
|
})
|
|
108
110
|
// In standalone lazy bundle mode, the lazy bundle will
|
|
109
111
|
// also has chunk.id "main", it will be conflict with the
|
|
@@ -124,7 +126,7 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
124
126
|
const footer = this.#getBannerType(filename) === 'script'
|
|
125
127
|
? loadScriptFooter
|
|
126
128
|
: loadBundleFooter;
|
|
127
|
-
return amdFooter('[name].js') + footer;
|
|
129
|
+
return amdFooter('[name].js', iife) + footer;
|
|
128
130
|
},
|
|
129
131
|
}).apply(compiler);
|
|
130
132
|
}
|
|
@@ -173,7 +175,10 @@ const loadBundleBanner = (strictMode = true) => `(function(){
|
|
|
173
175
|
function initBundle(lynxCoreInject) {
|
|
174
176
|
var tt = lynxCoreInject.tt;
|
|
175
177
|
`;
|
|
176
|
-
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
|
+
(() => {`;
|
|
177
182
|
return (`
|
|
178
183
|
tt.define("${moduleId}", function(require, module, exports, ${injectStr}) {
|
|
179
184
|
lynx = lynx || {};
|
|
@@ -182,9 +187,11 @@ ${overrideRuntimePromise ? `var Promise = lynx.Promise;` : ''}
|
|
|
182
187
|
fetch = fetch || lynx.fetch;
|
|
183
188
|
requestAnimationFrame = requestAnimationFrame || lynx.requestAnimationFrame;
|
|
184
189
|
cancelAnimationFrame = cancelAnimationFrame || lynx.cancelAnimationFrame;
|
|
190
|
+
${iifeWrapper}
|
|
185
191
|
`);
|
|
186
192
|
};
|
|
187
|
-
const amdFooter = (moduleId) => `
|
|
193
|
+
const amdFooter = (moduleId, iife) => `
|
|
194
|
+
${iife ? '' : '})();'}
|
|
188
195
|
});
|
|
189
196
|
return tt.require("${moduleId}");`;
|
|
190
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.3",
|
|
4
4
|
"description": "Use runtime wrapper which allow JavaScript to be load by Lynx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lynx-js/webpack-runtime-globals": "0.0.
|
|
35
|
+
"@lynx-js/webpack-runtime-globals": "0.0.6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@microsoft/api-extractor": "7.52.
|
|
39
|
-
"webpack": "^5.
|
|
38
|
+
"@microsoft/api-extractor": "7.52.11",
|
|
39
|
+
"webpack": "^5.101.3",
|
|
40
40
|
"@lynx-js/test-tools": "0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|