@lynx-js/externals-loading-webpack-plugin-canary 0.0.3 → 0.0.4-canary-20260304-8517e2c0
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 +23 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/externals-loading-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.0.4-canary-20260304153645-8517e2c0f81a61fc693fb44e71d15f8f1aa1c52d
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Support bundle and load css in external bundle ([#2143](https://github.com/lynx-family/lynx-stack/pull/2143))
|
|
8
|
+
|
|
3
9
|
## 0.0.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -20,18 +26,18 @@
|
|
|
20
26
|
|
|
21
27
|
```js
|
|
22
28
|
// webpack.config.js
|
|
23
|
-
import { ExternalsLoadingPlugin } from
|
|
29
|
+
import { ExternalsLoadingPlugin } from "@lynx-js/externals-loading-webpack-plugin";
|
|
24
30
|
|
|
25
31
|
export default {
|
|
26
32
|
plugins: [
|
|
27
33
|
new ExternalsLoadingPlugin({
|
|
28
|
-
mainThreadLayer:
|
|
29
|
-
backgroundLayer:
|
|
34
|
+
mainThreadLayer: "main-thread",
|
|
35
|
+
backgroundLayer: "background",
|
|
30
36
|
externals: {
|
|
31
37
|
lodash: {
|
|
32
|
-
url:
|
|
33
|
-
background: { sectionPath:
|
|
34
|
-
mainThread: { sectionPath:
|
|
38
|
+
url: "http://lodash.lynx.bundle",
|
|
39
|
+
background: { sectionPath: "background" },
|
|
40
|
+
mainThread: { sectionPath: "main-thread" },
|
|
35
41
|
},
|
|
36
42
|
},
|
|
37
43
|
}),
|
package/lib/index.js
CHANGED
|
@@ -73,6 +73,7 @@ export class ExternalsLoadingPlugin {
|
|
|
73
73
|
else {
|
|
74
74
|
return '';
|
|
75
75
|
}
|
|
76
|
+
const isMainThreadLayer = layer === 'mainThread';
|
|
76
77
|
for (const [pkgName, external] of Object.entries(externalsLoadingPluginOptions.externals)) {
|
|
77
78
|
externalsMap.set(external.libraryName ?? pkgName, external);
|
|
78
79
|
}
|
|
@@ -89,8 +90,19 @@ function createLoadExternalAsync(handler, sectionPath) {
|
|
|
89
90
|
if (response.code === 0) {
|
|
90
91
|
try {
|
|
91
92
|
const result = lynx.loadScript(sectionPath, { bundleName: response.url });
|
|
93
|
+
${isMainThreadLayer
|
|
94
|
+
? `
|
|
95
|
+
// TODO: Use configured layer suffix instead of hard-coded __main-thread for CSS section lookup.
|
|
96
|
+
const styleSheet = __LoadStyleSheet(sectionPath.replace('__main-thread', '') + ':CSS', response.url);
|
|
97
|
+
if (styleSheet !== null) {
|
|
98
|
+
__AdoptStyleSheet(styleSheet);
|
|
99
|
+
__FlushElementTree();
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
: ''}
|
|
92
103
|
resolve(result)
|
|
93
104
|
} catch (error) {
|
|
105
|
+
console.error(error)
|
|
94
106
|
reject(new Error('Failed to load script ' + sectionPath + ' in ' + response.url, { cause: error }))
|
|
95
107
|
}
|
|
96
108
|
} else {
|
|
@@ -104,8 +116,19 @@ function createLoadExternalSync(handler, sectionPath, timeout) {
|
|
|
104
116
|
if (response.code === 0) {
|
|
105
117
|
try {
|
|
106
118
|
const result = lynx.loadScript(sectionPath, { bundleName: response.url });
|
|
119
|
+
${isMainThreadLayer
|
|
120
|
+
? `
|
|
121
|
+
// TODO: Use configured layer suffix instead of hard-coded __main-thread for CSS section lookup.
|
|
122
|
+
const styleSheet = __LoadStyleSheet(sectionPath.replace('__main-thread', '') + ':CSS', response.url);
|
|
123
|
+
if (styleSheet !== null) {
|
|
124
|
+
__AdoptStyleSheet(styleSheet);
|
|
125
|
+
__FlushElementTree();
|
|
126
|
+
}
|
|
127
|
+
`
|
|
128
|
+
: ''}
|
|
107
129
|
return result
|
|
108
130
|
} catch (error) {
|
|
131
|
+
console.error(error)
|
|
109
132
|
throw new Error('Failed to load script ' + sectionPath + ' in ' + response.url, { cause: error })
|
|
110
133
|
}
|
|
111
134
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/externals-loading-webpack-plugin-canary",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-canary-20260304-8517e2c0",
|
|
4
4
|
"description": "A webpack plugin to load lynx external bundles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rspack/core": "1.7.
|
|
35
|
+
"@rspack/core": "1.7.6",
|
|
36
36
|
"foo": "./test/foo",
|
|
37
37
|
"@lynx-js/test-tools": "0.0.0"
|
|
38
38
|
},
|