@lynx-js/externals-loading-webpack-plugin-canary 0.0.1 → 0.0.2-canary-20251225-6bccf69c
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.d.ts +112 -106
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/externals-loading-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.0.2-canary-20251225040646-6bccf69cc42fa754d2e8e58d1911b1c4d844a3a0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Export `ExternalValue` ts type. ([#2037](https://github.com/lynx-family/lynx-stack/pull/2037))
|
|
8
|
+
|
|
3
9
|
## 0.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -8,18 +14,18 @@
|
|
|
8
14
|
|
|
9
15
|
```js
|
|
10
16
|
// webpack.config.js
|
|
11
|
-
import { ExternalsLoadingPlugin } from
|
|
17
|
+
import { ExternalsLoadingPlugin } from "@lynx-js/externals-loading-webpack-plugin";
|
|
12
18
|
|
|
13
19
|
export default {
|
|
14
20
|
plugins: [
|
|
15
21
|
new ExternalsLoadingPlugin({
|
|
16
|
-
mainThreadLayer:
|
|
17
|
-
backgroundLayer:
|
|
22
|
+
mainThreadLayer: "main-thread",
|
|
23
|
+
backgroundLayer: "background",
|
|
18
24
|
externals: {
|
|
19
25
|
lodash: {
|
|
20
|
-
url:
|
|
21
|
-
background: { sectionPath:
|
|
22
|
-
mainThread: { sectionPath:
|
|
26
|
+
url: "http://lodash.lynx.bundle",
|
|
27
|
+
background: { sectionPath: "background" },
|
|
28
|
+
mainThread: { sectionPath: "main-thread" },
|
|
23
29
|
},
|
|
24
30
|
},
|
|
25
31
|
}),
|
package/lib/index.d.ts
CHANGED
|
@@ -63,112 +63,118 @@ export interface ExternalsLoadingPluginOptions {
|
|
|
63
63
|
* };
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
externals: Record<string,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
66
|
+
externals: Record<string, ExternalValue>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The value item of the externals.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export interface ExternalValue {
|
|
74
|
+
/**
|
|
75
|
+
* The bundle url of the library. The library source should be placed in `customSections`.
|
|
76
|
+
*/
|
|
77
|
+
url: string;
|
|
78
|
+
/**
|
|
79
|
+
* The name of the library. Same as https://webpack.js.org/configuration/externals/#string.
|
|
80
|
+
*
|
|
81
|
+
* By default, the library name is the same as the externals key. For example:
|
|
82
|
+
*
|
|
83
|
+
* The config
|
|
84
|
+
*
|
|
85
|
+
* ```js
|
|
86
|
+
* ExternalsLoadingPlugin({
|
|
87
|
+
* externals: {
|
|
88
|
+
* lodash: {
|
|
89
|
+
* url: '……',
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
* })
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Will generate the following webpack externals config:
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* externals: {
|
|
99
|
+
* lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].lodash',
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* If one external bundle contains multiple modules, should set the same library name to ensure it's loaded only once. For example:
|
|
104
|
+
*
|
|
105
|
+
* ```js
|
|
106
|
+
* ExternalsLoadingPlugin({
|
|
107
|
+
* externals: {
|
|
108
|
+
* lodash: {
|
|
109
|
+
* libraryName: 'Lodash',
|
|
110
|
+
* url: '……',
|
|
111
|
+
* },
|
|
112
|
+
* 'lodash-es': {
|
|
113
|
+
* libraryName: 'Lodash',
|
|
114
|
+
* url: '……',
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
* })
|
|
118
|
+
* ```
|
|
119
|
+
* Will generate the following webpack externals config:
|
|
120
|
+
*
|
|
121
|
+
* ```js
|
|
122
|
+
* externals: {
|
|
123
|
+
* lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
|
|
124
|
+
* 'lodash-es': 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* You can pass an array to specify subpath of the external. Same as https://webpack.js.org/configuration/externals/#string-1. For example:
|
|
129
|
+
*
|
|
130
|
+
* ```js
|
|
131
|
+
* ExternalsLoadingPlugin({
|
|
132
|
+
* externals: {
|
|
133
|
+
* preact: {
|
|
134
|
+
* libraryName: ['ReactLynx', 'Preact'],
|
|
135
|
+
* url: '……',
|
|
136
|
+
* },
|
|
137
|
+
* }
|
|
138
|
+
* })
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* Will generate the following webpack externals config:
|
|
142
|
+
*
|
|
143
|
+
* ```js
|
|
144
|
+
* externals: {
|
|
145
|
+
* preact: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].ReactLynx.Preact',
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @defaultValue `undefined`
|
|
150
|
+
*
|
|
151
|
+
* @example `Lodash`
|
|
152
|
+
*/
|
|
153
|
+
libraryName?: string | string[];
|
|
154
|
+
/**
|
|
155
|
+
* Whether the source should be loaded asynchronously or not.
|
|
156
|
+
*
|
|
157
|
+
* @defaultValue `true`
|
|
158
|
+
*/
|
|
159
|
+
async?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* The options of the background layer.
|
|
162
|
+
*
|
|
163
|
+
* @defaultValue `undefined`
|
|
164
|
+
*/
|
|
165
|
+
background?: LayerOptions;
|
|
166
|
+
/**
|
|
167
|
+
* The options of the main-thread layer.
|
|
168
|
+
*
|
|
169
|
+
* @defaultValue `undefined`
|
|
170
|
+
*/
|
|
171
|
+
mainThread?: LayerOptions;
|
|
172
|
+
/**
|
|
173
|
+
* The wait time in milliseconds.
|
|
174
|
+
*
|
|
175
|
+
* @defaultValue `2000`
|
|
176
|
+
*/
|
|
177
|
+
timeout?: number;
|
|
172
178
|
}
|
|
173
179
|
/**
|
|
174
180
|
* The options of the background or main-thread layer.
|