@lynx-js/externals-loading-webpack-plugin-canary 0.2.0 → 0.2.1-canary-20260708-0d8a1843
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 -6
- package/lib/index.js +15 -4
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/externals-loading-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.2.1-canary-20260708040538-0d8a18437178b669c77de05c337bd9f248bfa45f
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `async: true` externals with a subpath `libraryName` (e.g. `['ReactLynx', 'React']`) resolving to `undefined`. The generated `promise` external now picks all subpath segments after the mounted namespace promise resolves, instead of reading them synchronously off the pending promise. ([#2928](https://github.com/lynx-family/lynx-stack/pull/2928))
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -61,18 +67,18 @@
|
|
|
61
67
|
|
|
62
68
|
```js
|
|
63
69
|
// webpack.config.js
|
|
64
|
-
import { ExternalsLoadingPlugin } from
|
|
70
|
+
import { ExternalsLoadingPlugin } from "@lynx-js/externals-loading-webpack-plugin";
|
|
65
71
|
|
|
66
72
|
export default {
|
|
67
73
|
plugins: [
|
|
68
74
|
new ExternalsLoadingPlugin({
|
|
69
|
-
mainThreadLayer:
|
|
70
|
-
backgroundLayer:
|
|
75
|
+
mainThreadLayer: "main-thread",
|
|
76
|
+
backgroundLayer: "background",
|
|
71
77
|
externals: {
|
|
72
78
|
lodash: {
|
|
73
|
-
url:
|
|
74
|
-
background: { sectionPath:
|
|
75
|
-
mainThread: { sectionPath:
|
|
79
|
+
url: "http://lodash.lynx.bundle",
|
|
80
|
+
background: { sectionPath: "background" },
|
|
81
|
+
mainThread: { sectionPath: "main-thread" },
|
|
76
82
|
},
|
|
77
83
|
},
|
|
78
84
|
}),
|
package/lib/index.js
CHANGED
|
@@ -316,10 +316,21 @@ function createLoadExternalSync(handler, sectionPath, timeout) {
|
|
|
316
316
|
&& externals[request]?.[currentLayer]) {
|
|
317
317
|
const isAsync = externals[request]?.async ?? true;
|
|
318
318
|
const libraryName = externals[request]?.libraryName ?? request;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
const names = Array.isArray(libraryName) ? libraryName : [libraryName];
|
|
320
|
+
if (isAsync) {
|
|
321
|
+
// A `promise` external must be a single expression evaluating to a
|
|
322
|
+
// promise whose resolved value becomes the module exports. The
|
|
323
|
+
// runtime module mounts one promise per library that resolves to
|
|
324
|
+
// the whole namespace, so subpaths have to be picked after that
|
|
325
|
+
// promise resolves — an array request would apply the property
|
|
326
|
+
// access synchronously on the pending promise and yield undefined.
|
|
327
|
+
const mount = `${getLynxExternalGlobal(globalObject)}[${JSON.stringify(names[0])}]`;
|
|
328
|
+
const accessor = names.slice(1).map((name) => `[${JSON.stringify(name)}]`).join('');
|
|
329
|
+
return callback(undefined, accessor
|
|
330
|
+
? `Promise.resolve(${mount}).then(function (m) { return m${accessor}; })`
|
|
331
|
+
: mount, 'promise');
|
|
332
|
+
}
|
|
333
|
+
return callback(undefined, [getLynxExternalGlobal(globalObject), ...names], undefined);
|
|
323
334
|
}
|
|
324
335
|
// Continue without externalizing the import
|
|
325
336
|
callback();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/externals-loading-webpack-plugin-canary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-canary-20260708-0d8a1843",
|
|
4
4
|
"description": "A webpack plugin to load lynx external bundles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -32,9 +32,8 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rspack/core": "
|
|
36
|
-
"@
|
|
37
|
-
"@rstest/core": "0.8.1",
|
|
35
|
+
"@rspack/core": "2.0.8",
|
|
36
|
+
"@rstest/core": "0.10.5",
|
|
38
37
|
"bar": "./test/helpers/external-bundle-mock/bar",
|
|
39
38
|
"baz": "./test/helpers/external-bundle-mock/baz",
|
|
40
39
|
"foo": "./test/helpers/external-bundle-mock/foo",
|