@lynx-js/runtime-wrapper-webpack-plugin-canary 0.2.3 → 0.2.4-canary-20260903-cdceffc6
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 +8 -0
- package/lib/RuntimeWrapperWebpackPlugin.js +55 -47
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lynx-js/runtime-wrapper-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.2.4-canary-20260903112143-cdceffc6f3fb9ac7b5ce1f48b7edb53c7788c057
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Skip the background runtime wrapper on any asset marked `lynx:main-thread` instead of matching filenames, and mark the main-thread assets of an external bundle by the layer of their modules, so a main-thread entry an external bundle names itself is no longer wrapped. ([#3751](https://github.com/lynx-family/lynx-stack/pull/3751))
|
|
8
|
+
- Updated dependencies [[`76126fc`](https://github.com/lynx-family/lynx-stack/commit/76126fcad0f16e649c372d22c013e90ad88640df)]:
|
|
9
|
+
- @lynx-js/webpack-runtime-globals@0.0.8-canary-20260903112143-cdceffc6f3fb9ac7b5ce1f48b7edb53c7788c057
|
|
10
|
+
|
|
3
11
|
## 0.2.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -82,7 +82,6 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
82
82
|
this.compiler = compiler;
|
|
83
83
|
this.options = options;
|
|
84
84
|
const { targetSdkVersion, test, experimental_isLazyBundle } = options;
|
|
85
|
-
const { BannerPlugin } = compiler.webpack;
|
|
86
85
|
const isDev = process.env['NODE_ENV'] === 'development'
|
|
87
86
|
|| compiler.options.mode === 'development';
|
|
88
87
|
let injectStr = defaultInjectStr;
|
|
@@ -90,52 +89,61 @@ class RuntimeWrapperWebpackPluginImpl {
|
|
|
90
89
|
injectStr = options.injectVars(defaultInjectVars).join(',');
|
|
91
90
|
}
|
|
92
91
|
const iife = compiler.options.output.iife ?? true;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
92
|
+
const wrapperHeader = ({ chunk, filename }) => {
|
|
93
|
+
const banner = this.#getBannerType(filename) === 'script'
|
|
94
|
+
? loadScriptBanner()
|
|
95
|
+
: loadBundleBanner();
|
|
96
|
+
return banner
|
|
97
|
+
+ amdBanner({
|
|
98
|
+
// TODO: config
|
|
99
|
+
injectStr,
|
|
100
|
+
overrideRuntimePromise: true,
|
|
101
|
+
moduleId: '[name].js',
|
|
102
|
+
targetSdkVersion,
|
|
103
|
+
iife,
|
|
104
|
+
})
|
|
105
|
+
// In standalone lazy bundle mode, the lazy bundle will
|
|
106
|
+
// also has chunk.id "main", it will be conflict with the
|
|
107
|
+
// consumer project.
|
|
108
|
+
// We disable it for standalone lazy bundle since we do not
|
|
109
|
+
// support HMR for standalone lazy bundle now.
|
|
110
|
+
+ (isDev && !experimental_isLazyBundle
|
|
111
|
+
? lynxChunkEntries(JSON.stringify(chunk.id))
|
|
112
|
+
: '');
|
|
113
|
+
};
|
|
114
|
+
const wrapperFooter = (filename) => {
|
|
115
|
+
const footer = this.#getBannerType(filename) === 'script'
|
|
116
|
+
? loadScriptFooter
|
|
117
|
+
: loadBundleFooter;
|
|
118
|
+
return amdFooter('[name].js', iife) + footer;
|
|
119
|
+
};
|
|
120
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
|
|
121
|
+
const { ModuleFilenameHelpers, sources: { ConcatSource } } = compiler.webpack;
|
|
122
|
+
compilation.hooks.processAssets.tap({
|
|
123
|
+
name: this.name,
|
|
124
|
+
// Wrap at PROCESS_ASSETS_STAGE_NONE (0), after the release BannerPlugins
|
|
125
|
+
// the legacy source-map plugin + debug-metadata, at/around ADDITIONS
|
|
126
|
+
// (-100) so the wrapper stays outermost and their `_SetSourceMapRelease`
|
|
127
|
+
// runtimes land INSIDE it, yet still before DEV_TOOLING so the source map
|
|
128
|
+
// accounts for it.
|
|
129
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_NONE,
|
|
130
|
+
}, () => {
|
|
131
|
+
for (const chunk of compilation.chunks) {
|
|
132
|
+
for (const filename of chunk.files) {
|
|
133
|
+
if (!ModuleFilenameHelpers.matchObject({ test: test }, filename)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (compilation.getAsset(filename)?.info['lynx:main-thread']) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const data = { chunk, filename };
|
|
140
|
+
const header = compilation.getPath(wrapperHeader(data), data);
|
|
141
|
+
const footer = compilation.getPath(wrapperFooter(filename), data);
|
|
142
|
+
compilation.updateAsset(filename, (source) => new ConcatSource(header, '\n', source, '\n', footer));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
139
147
|
}
|
|
140
148
|
#getBannerType(filename) {
|
|
141
149
|
const bannerType = this.options.bannerType(filename);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/runtime-wrapper-webpack-plugin-canary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-canary-20260903-cdceffc6",
|
|
4
4
|
"description": "Use runtime wrapper which allow JavaScript to be load by Lynx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lynx-js/webpack-runtime-globals": "npm:@lynx-js/webpack-runtime-globals-canary@0.0.
|
|
35
|
+
"@lynx-js/webpack-runtime-globals": "npm:@lynx-js/webpack-runtime-globals-canary@0.0.8-canary-20260903-cdceffc6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@microsoft/api-extractor": "7.58.12",
|
|
39
|
-
"@rspack/core": "2.1.
|
|
40
|
-
"@rstest/core": "0.11.
|
|
39
|
+
"@rspack/core": "2.1.7",
|
|
40
|
+
"@rstest/core": "0.11.6",
|
|
41
41
|
"@types/node": "^24.13.3",
|
|
42
42
|
"@lynx-js/test-tools": "0.0.0"
|
|
43
43
|
},
|