@module-federation/managers 0.0.0-docs-remove-invalid-lark-link-20251205062649
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/LICENSE +21 -0
- package/dist/index.cjs.js +495 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +486 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/src/BasicPluginOptionsManager.d.ts +10 -0
- package/dist/src/ContainerManager.d.ts +20 -0
- package/dist/src/PKGJsonManager.d.ts +6 -0
- package/dist/src/RemoteManager.d.ts +18 -0
- package/dist/src/SharedManager.d.ts +18 -0
- package/dist/src/constant.d.ts +2 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/types.d.ts +16 -0
- package/dist/src/utils.d.ts +4 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present hanric(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# `@module-federation/managers` Documentation
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present hanric(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var sdk = require('@module-federation/sdk');
|
|
5
|
+
var finder = require('find-pkg');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var fs$1 = require('fs-extra');
|
|
8
|
+
|
|
9
|
+
class BasicPluginOptionsManager {
|
|
10
|
+
constructor(root = process.cwd()) {
|
|
11
|
+
this._root = root;
|
|
12
|
+
}
|
|
13
|
+
get enable() {
|
|
14
|
+
return Boolean(this._options);
|
|
15
|
+
}
|
|
16
|
+
get options() {
|
|
17
|
+
return this._options;
|
|
18
|
+
}
|
|
19
|
+
get root() {
|
|
20
|
+
return this._root;
|
|
21
|
+
}
|
|
22
|
+
init(options, extraArgs) {
|
|
23
|
+
this._options = options;
|
|
24
|
+
}
|
|
25
|
+
setOptions(options) {
|
|
26
|
+
this._options = options;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class PKGJsonManager {
|
|
31
|
+
setPKGJson(pkg) {
|
|
32
|
+
this._pkg = pkg;
|
|
33
|
+
}
|
|
34
|
+
readPKGJson(root = process.cwd()) {
|
|
35
|
+
if (this._pkg) {
|
|
36
|
+
return this._pkg;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
// eslint-disable-next-line no-restricted-globals
|
|
40
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
|
|
41
|
+
this._pkg = pkg;
|
|
42
|
+
return pkg;
|
|
43
|
+
}
|
|
44
|
+
catch (_err) {
|
|
45
|
+
try {
|
|
46
|
+
const pkg = finder.sync(root);
|
|
47
|
+
this._pkg = pkg;
|
|
48
|
+
return pkg;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
sdk.logger.error(err);
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
57
|
+
const pkg = this.readPKGJson(root);
|
|
58
|
+
return pkg?.['mf']?.type === sdk.MFModuleType.NPM
|
|
59
|
+
? sdk.MFModuleType.NPM
|
|
60
|
+
: sdk.MFModuleType.APP;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const LOCAL_BUILD_VERSION = 'local';
|
|
65
|
+
const UNKNOWN_MODULE_NAME = 'UNKNOWN';
|
|
66
|
+
|
|
67
|
+
function processFn(options, normalizeSimple, normalizeOptions, fn) {
|
|
68
|
+
const object = (obj) => {
|
|
69
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
70
|
+
if (typeof value === 'string') {
|
|
71
|
+
fn(key, normalizeSimple(value, key));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
fn(key, normalizeOptions(value, key));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const array = (items) => {
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
if (typeof item === 'string') {
|
|
81
|
+
fn(item, normalizeSimple(item, item));
|
|
82
|
+
}
|
|
83
|
+
else if (item && typeof item === 'object') {
|
|
84
|
+
object(item);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error('Unexpected options format');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (!options) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
else if (Array.isArray(options)) {
|
|
95
|
+
array(options);
|
|
96
|
+
}
|
|
97
|
+
else if (typeof options === 'object') {
|
|
98
|
+
object(options);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new Error('Unexpected options format');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function parseOptions(options, normalizeSimple, normalizeOptions) {
|
|
105
|
+
const items = [];
|
|
106
|
+
processFn(options, normalizeSimple, normalizeOptions, (key, value) => {
|
|
107
|
+
items.push([key, value]);
|
|
108
|
+
});
|
|
109
|
+
return items;
|
|
110
|
+
}
|
|
111
|
+
function getBuildVersion(root) {
|
|
112
|
+
if (process.env['MF_BUILD_VERSION']) {
|
|
113
|
+
return process.env['MF_BUILD_VERSION'];
|
|
114
|
+
}
|
|
115
|
+
const pkg = new PKGJsonManager().readPKGJson(root);
|
|
116
|
+
if (pkg?.['version'] && typeof pkg['version'] === 'string') {
|
|
117
|
+
return pkg['version'];
|
|
118
|
+
}
|
|
119
|
+
return LOCAL_BUILD_VERSION;
|
|
120
|
+
}
|
|
121
|
+
function getBuildName() {
|
|
122
|
+
return process.env['MF_BUILD_NAME'];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
126
|
+
__proto__: null,
|
|
127
|
+
getBuildName: getBuildName,
|
|
128
|
+
getBuildVersion: getBuildVersion,
|
|
129
|
+
parseOptions: parseOptions
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
function normalizeExposeModuleName(exposeKey) {
|
|
133
|
+
const relativePath = path.relative('.', exposeKey);
|
|
134
|
+
if (!relativePath) {
|
|
135
|
+
return 'ExposeEntry';
|
|
136
|
+
}
|
|
137
|
+
return relativePath;
|
|
138
|
+
}
|
|
139
|
+
class ContainerManager extends BasicPluginOptionsManager {
|
|
140
|
+
get enable() {
|
|
141
|
+
return Boolean(this.options.name &&
|
|
142
|
+
this.options.exposes &&
|
|
143
|
+
(Array.isArray(this.options.exposes)
|
|
144
|
+
? this.options.exposes.length > 0
|
|
145
|
+
: Object.keys(this.options.exposes).length > 0));
|
|
146
|
+
}
|
|
147
|
+
get globalEntryName() {
|
|
148
|
+
const { name, library } = this.options;
|
|
149
|
+
if (library) {
|
|
150
|
+
if (typeof library.name === 'string') {
|
|
151
|
+
return library.name;
|
|
152
|
+
}
|
|
153
|
+
return name;
|
|
154
|
+
}
|
|
155
|
+
return name;
|
|
156
|
+
}
|
|
157
|
+
get containerPluginExposesOptions() {
|
|
158
|
+
const { exposes } = this.options;
|
|
159
|
+
const parsedOptions = parseOptions(exposes, (item, key) => ({
|
|
160
|
+
import: Array.isArray(item) ? item : [item],
|
|
161
|
+
name: sdk.generateExposeFilename(key, false),
|
|
162
|
+
}), (item, key) => ({
|
|
163
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
164
|
+
name: item.name || sdk.generateExposeFilename(key, false),
|
|
165
|
+
}));
|
|
166
|
+
return parsedOptions.reduce((sum, item) => {
|
|
167
|
+
const [exposeKey, exposeObj] = item;
|
|
168
|
+
sum[exposeKey] = exposeObj;
|
|
169
|
+
return sum;
|
|
170
|
+
}, {});
|
|
171
|
+
}
|
|
172
|
+
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
|
|
173
|
+
get fileExposeKeyMap() {
|
|
174
|
+
const parsedOptions = this._parseOptions();
|
|
175
|
+
return parsedOptions.reduce((sum, item) => {
|
|
176
|
+
const [exposeKey, exposeObject] = item;
|
|
177
|
+
exposeObject.import.forEach((exposeFile) => {
|
|
178
|
+
const exposeFileWithoutExt = exposeFile.replace(path.extname(exposeFile), '');
|
|
179
|
+
sum[exposeFileWithoutExt] ||= new Set();
|
|
180
|
+
sum[exposeFileWithoutExt].add(exposeKey);
|
|
181
|
+
});
|
|
182
|
+
return sum;
|
|
183
|
+
}, {});
|
|
184
|
+
}
|
|
185
|
+
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
|
|
186
|
+
get exposeFileNameImportMap() {
|
|
187
|
+
const { exposes } = this.options;
|
|
188
|
+
const parsedOptions = parseOptions(exposes, (item, key) => ({
|
|
189
|
+
import: Array.isArray(item) ? item : [item],
|
|
190
|
+
name: sdk.generateExposeFilename(key, false),
|
|
191
|
+
}), (item, key) => ({
|
|
192
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
193
|
+
name: item.name || sdk.generateExposeFilename(key, false),
|
|
194
|
+
}));
|
|
195
|
+
return parsedOptions.reduce((sum, item) => {
|
|
196
|
+
const [_exposeKey, exposeObj] = item;
|
|
197
|
+
const { name, import: importPath } = exposeObj;
|
|
198
|
+
sum[name] = importPath;
|
|
199
|
+
return sum;
|
|
200
|
+
}, {});
|
|
201
|
+
}
|
|
202
|
+
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
|
|
203
|
+
get exposeObject() {
|
|
204
|
+
const parsedOptions = this._parseOptions();
|
|
205
|
+
return parsedOptions.reduce((sum, item) => {
|
|
206
|
+
const [exposeKey, exposeObject] = item;
|
|
207
|
+
sum[exposeKey] = [];
|
|
208
|
+
exposeObject.import.forEach((item) => {
|
|
209
|
+
const relativePath = path.relative('.', item.replace(path.extname(item), ''));
|
|
210
|
+
sum[exposeKey].push(relativePath);
|
|
211
|
+
});
|
|
212
|
+
return sum;
|
|
213
|
+
}, {});
|
|
214
|
+
}
|
|
215
|
+
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
|
|
216
|
+
get exposeFiles() {
|
|
217
|
+
const parsedOptions = this._parseOptions();
|
|
218
|
+
return parsedOptions.reduce((sum, item) => {
|
|
219
|
+
const [_exposeKey, exposeObject] = item;
|
|
220
|
+
sum.push(...exposeObject.import);
|
|
221
|
+
return sum;
|
|
222
|
+
}, []);
|
|
223
|
+
}
|
|
224
|
+
get manifestModuleInfos() {
|
|
225
|
+
if (this._manifestModuleInfos) {
|
|
226
|
+
return this._manifestModuleInfos;
|
|
227
|
+
}
|
|
228
|
+
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
|
|
229
|
+
const parsedOptions = this._parseOptions();
|
|
230
|
+
this._manifestModuleInfos = parsedOptions.reduce((sum, item) => {
|
|
231
|
+
const [exposeKey, exposeObject] = item;
|
|
232
|
+
sum[exposeKey] = {
|
|
233
|
+
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
|
|
234
|
+
file: exposeObject.import,
|
|
235
|
+
};
|
|
236
|
+
return sum;
|
|
237
|
+
}, {});
|
|
238
|
+
return this._manifestModuleInfos;
|
|
239
|
+
}
|
|
240
|
+
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
|
|
241
|
+
get webpackEntry() {
|
|
242
|
+
return Object.values(this.manifestModuleInfos).reduce((sum, cur) => {
|
|
243
|
+
const entry = cur.name === 'ExposeEntry'
|
|
244
|
+
? 'index'
|
|
245
|
+
: cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
|
|
246
|
+
sum[entry] = cur.file;
|
|
247
|
+
return sum;
|
|
248
|
+
}, {});
|
|
249
|
+
}
|
|
250
|
+
_parseOptions() {
|
|
251
|
+
if (this._parsedOptions) {
|
|
252
|
+
return this._parsedOptions;
|
|
253
|
+
}
|
|
254
|
+
this._parsedOptions = parseOptions(this.options.exposes, (item) => ({
|
|
255
|
+
import: Array.isArray(item) ? item : [item],
|
|
256
|
+
name: undefined,
|
|
257
|
+
}), (item) => ({
|
|
258
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
259
|
+
name: undefined,
|
|
260
|
+
}));
|
|
261
|
+
return this._parsedOptions;
|
|
262
|
+
}
|
|
263
|
+
init(options) {
|
|
264
|
+
this.setOptions(options);
|
|
265
|
+
this.validate(options.name);
|
|
266
|
+
}
|
|
267
|
+
validate(name) {
|
|
268
|
+
if (!name) {
|
|
269
|
+
throw new Error(`container name can not be empty!`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getEntry(remoteObj) {
|
|
275
|
+
if (typeof remoteObj === 'string') {
|
|
276
|
+
return remoteObj;
|
|
277
|
+
}
|
|
278
|
+
if (typeof remoteObj.external === 'string') {
|
|
279
|
+
return remoteObj.external;
|
|
280
|
+
}
|
|
281
|
+
throw new Error('Not support "array" remote value yet!');
|
|
282
|
+
}
|
|
283
|
+
class RemoteManager extends BasicPluginOptionsManager {
|
|
284
|
+
constructor() {
|
|
285
|
+
super(...arguments);
|
|
286
|
+
this.normalizedOptions = {};
|
|
287
|
+
}
|
|
288
|
+
get enable() {
|
|
289
|
+
return Boolean(this.remotes &&
|
|
290
|
+
(Array.isArray(this.remotes)
|
|
291
|
+
? this.remotes.length > 0
|
|
292
|
+
: Object.keys(this.remotes).length > 0));
|
|
293
|
+
}
|
|
294
|
+
get statsRemoteWithEmptyUsedIn() {
|
|
295
|
+
const { name } = this.options;
|
|
296
|
+
return Object.keys(this.normalizedOptions).reduce((sum, cur) => {
|
|
297
|
+
const normalizedOption = this.normalizedOptions[cur];
|
|
298
|
+
let curObj;
|
|
299
|
+
if ('entry' in normalizedOption) {
|
|
300
|
+
curObj = {
|
|
301
|
+
entry: normalizedOption.entry,
|
|
302
|
+
alias: normalizedOption.alias,
|
|
303
|
+
moduleName: UNKNOWN_MODULE_NAME,
|
|
304
|
+
federationContainerName: normalizedOption.name,
|
|
305
|
+
consumingFederationContainerName: name,
|
|
306
|
+
usedIn: [UNKNOWN_MODULE_NAME],
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
curObj = {
|
|
311
|
+
alias: normalizedOption.alias,
|
|
312
|
+
moduleName: UNKNOWN_MODULE_NAME,
|
|
313
|
+
version: normalizedOption.version,
|
|
314
|
+
federationContainerName: normalizedOption.name,
|
|
315
|
+
consumingFederationContainerName: name,
|
|
316
|
+
usedIn: [UNKNOWN_MODULE_NAME],
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
sum.push(curObj);
|
|
320
|
+
return sum;
|
|
321
|
+
}, []);
|
|
322
|
+
}
|
|
323
|
+
// 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
|
|
324
|
+
// ↓↓↓
|
|
325
|
+
// {
|
|
326
|
+
// 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
|
|
327
|
+
// }
|
|
328
|
+
get dtsRemotes() {
|
|
329
|
+
return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias) => {
|
|
330
|
+
const remoteInfo = this.normalizedOptions[remoteAlias];
|
|
331
|
+
sum[remoteAlias] = sdk.composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
|
|
332
|
+
return sum;
|
|
333
|
+
}, {});
|
|
334
|
+
}
|
|
335
|
+
get remotes() {
|
|
336
|
+
return this.options.remotes;
|
|
337
|
+
}
|
|
338
|
+
// INFO: only support remoteType: script now
|
|
339
|
+
normalizeOptions(options = {}) {
|
|
340
|
+
this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias) => {
|
|
341
|
+
if (Array.isArray(options)) {
|
|
342
|
+
return sum;
|
|
343
|
+
}
|
|
344
|
+
const remoteInfo = options[remoteAlias];
|
|
345
|
+
if (Array.isArray(remoteInfo)) {
|
|
346
|
+
return sum;
|
|
347
|
+
}
|
|
348
|
+
let parsedOptions;
|
|
349
|
+
try {
|
|
350
|
+
parsedOptions = sdk.parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
// noop
|
|
354
|
+
}
|
|
355
|
+
if (!parsedOptions) {
|
|
356
|
+
return sum;
|
|
357
|
+
}
|
|
358
|
+
sum[remoteAlias] = {
|
|
359
|
+
...parsedOptions,
|
|
360
|
+
alias: remoteAlias,
|
|
361
|
+
shareScope: typeof remoteInfo === 'object'
|
|
362
|
+
? remoteInfo.shareScope || 'default'
|
|
363
|
+
: 'default',
|
|
364
|
+
};
|
|
365
|
+
return sum;
|
|
366
|
+
}, {});
|
|
367
|
+
}
|
|
368
|
+
init(options) {
|
|
369
|
+
this.setOptions(options);
|
|
370
|
+
this.normalizeOptions(options.remotes);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// @ts-ignore this pkg miss types
|
|
375
|
+
class SharedManager extends BasicPluginOptionsManager {
|
|
376
|
+
constructor() {
|
|
377
|
+
super(...arguments);
|
|
378
|
+
this.normalizedOptions = {};
|
|
379
|
+
}
|
|
380
|
+
get enable() {
|
|
381
|
+
return Boolean(Object.keys(this.sharedPluginOptions.shared).length);
|
|
382
|
+
}
|
|
383
|
+
get sharedPluginOptions() {
|
|
384
|
+
const normalizedShared = this.normalizedOptions;
|
|
385
|
+
const shared = Object.keys(normalizedShared).reduce((sum, cur) => {
|
|
386
|
+
const { singleton, requiredVersion, version, eager, shareScope, import: sharedImport, } = normalizedShared[cur];
|
|
387
|
+
sum[cur] = {
|
|
388
|
+
singleton,
|
|
389
|
+
requiredVersion,
|
|
390
|
+
version,
|
|
391
|
+
eager,
|
|
392
|
+
shareScope,
|
|
393
|
+
import: sharedImport,
|
|
394
|
+
};
|
|
395
|
+
return sum;
|
|
396
|
+
}, {});
|
|
397
|
+
return {
|
|
398
|
+
shared,
|
|
399
|
+
shareScope: this.options.shareScope || 'default',
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
findPkg(name, shareConfig) {
|
|
403
|
+
try {
|
|
404
|
+
let pkgPath = '';
|
|
405
|
+
let depName = name;
|
|
406
|
+
if (shareConfig.import) {
|
|
407
|
+
if (path.isAbsolute(shareConfig.import)) {
|
|
408
|
+
pkgPath = shareConfig.import;
|
|
409
|
+
}
|
|
410
|
+
else if (shareConfig.import.startsWith('.')) {
|
|
411
|
+
pkgPath = path.resolve(this.root, shareConfig.import);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
if (shareConfig.packageName) {
|
|
416
|
+
depName = shareConfig.packageName;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
pkgPath = pkgPath || require.resolve(depName, { paths: [this.root] });
|
|
420
|
+
const pkgJsonPath = finder.sync(pkgPath);
|
|
421
|
+
return {
|
|
422
|
+
pkg: JSON.parse(fs$1.readFileSync(pkgJsonPath, 'utf-8')),
|
|
423
|
+
path: '',
|
|
424
|
+
pkgPath: '',
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
catch (err) {
|
|
428
|
+
return {
|
|
429
|
+
pkg: {},
|
|
430
|
+
path: '',
|
|
431
|
+
pkgPath: '',
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
transformSharedConfig(sharedConfig) {
|
|
436
|
+
const defaultSharedConfig = {
|
|
437
|
+
singleton: true,
|
|
438
|
+
requiredVersion: undefined,
|
|
439
|
+
shareScope: 'default',
|
|
440
|
+
};
|
|
441
|
+
return {
|
|
442
|
+
...defaultSharedConfig,
|
|
443
|
+
...sharedConfig,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
normalizeOptions(options) {
|
|
447
|
+
const normalizedShared = {};
|
|
448
|
+
const sharedOptions = parseOptions(options, (item, key) => {
|
|
449
|
+
if (typeof item !== 'string')
|
|
450
|
+
throw new Error('Unexpected array in shared');
|
|
451
|
+
const config = item === key || !sdk.isRequiredVersion(item)
|
|
452
|
+
? {
|
|
453
|
+
import: item,
|
|
454
|
+
}
|
|
455
|
+
: {
|
|
456
|
+
import: key,
|
|
457
|
+
requiredVersion: item,
|
|
458
|
+
};
|
|
459
|
+
return config;
|
|
460
|
+
}, (item) => item);
|
|
461
|
+
sharedOptions.forEach((item) => {
|
|
462
|
+
const [sharedName, sharedOptions] = item;
|
|
463
|
+
const pkgInfo = this.findPkg(sharedName, sharedOptions);
|
|
464
|
+
const sharedConfig = this.transformSharedConfig(sharedOptions);
|
|
465
|
+
normalizedShared[sharedName] = {
|
|
466
|
+
...sharedConfig,
|
|
467
|
+
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined'
|
|
468
|
+
? sharedConfig.requiredVersion
|
|
469
|
+
: `^${pkgInfo.pkg['version']}`,
|
|
470
|
+
name: sharedName,
|
|
471
|
+
version: pkgInfo.pkg['version'],
|
|
472
|
+
eager: Boolean(sharedConfig.eager),
|
|
473
|
+
};
|
|
474
|
+
});
|
|
475
|
+
this.normalizedOptions = normalizedShared;
|
|
476
|
+
}
|
|
477
|
+
init(options) {
|
|
478
|
+
this.setOptions(options);
|
|
479
|
+
this.normalizeOptions(options.shared);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
484
|
+
__proto__: null
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
exports.BasicPluginOptionsManager = BasicPluginOptionsManager;
|
|
488
|
+
exports.ContainerManager = ContainerManager;
|
|
489
|
+
exports.PKGJsonManager = PKGJsonManager;
|
|
490
|
+
exports.RemoteManager = RemoteManager;
|
|
491
|
+
exports.SharedManager = SharedManager;
|
|
492
|
+
exports.UNKNOWN_MODULE_NAME = UNKNOWN_MODULE_NAME;
|
|
493
|
+
exports.types = types;
|
|
494
|
+
exports.utils = utils;
|
|
495
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/BasicPluginOptionsManager.ts","../../src/PKGJsonManager.ts","../../src/constant.ts","../../src/utils.ts","../../src/ContainerManager.ts","../../src/RemoteManager.ts","../../src/SharedManager.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["logger","MFModuleType","generateExposeFilename","composeKeyWithSeparator","parseEntry","findPkg","fs","isRequiredVersion"],"mappings":";;;;;;;;MAAa,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CAAY,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAA;AAC9B,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;;AAGnB,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;;AAG/B,IAAA,IAAI,OAAO,GAAA;QACT,OAAO,IAAI,CAAC,QAAwB;;AAGtC,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK;;IAGnB,IAAI,CAAC,OAAU,EAAE,SAA+B,EAAA;AAC9C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAGzB,IAAA,UAAU,CAAC,OAAU,E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Ae,EAAE,IAAI;iBACtB;AACP,YAAA,OAAO,MAAM;SACd,EACD,CAAC,IAAI,KAAK,IAAI,CACf;AAED,QAAA,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC7B,YAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAI;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC;YACvD,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC;YAC9D,gBAAgB,CAAC,UAAU,CAAC,GAAG;AAC7B,gBAAA,GAAG,YAAY;AACf,gBAAA,eAAe,EACb,OAAO,YAAY,CAAC,eAAe,KAAK;sBACpC,YAAY,CAAC;sBACb,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAE,CAAA;AAClC,gBAAA,IAAI,EAAE,UAAU;AAChB,gBAAA,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/B,gBAAA,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;aACnC;AACH,SAAC,CAAC;AAEF,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB;;AAGlC,IAAA,IAAI,CACX,OAA6D,EAAA;AAE7D,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AACxB,QAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;;AAExC;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { logger, MFModuleType, generateExposeFilename, composeKeyWithSeparator, parseEntry, isRequiredVersion } from '@module-federation/sdk';
|
|
3
|
+
import finder from 'find-pkg';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import fs$1 from 'fs-extra';
|
|
6
|
+
|
|
7
|
+
class BasicPluginOptionsManager {
|
|
8
|
+
constructor(root = process.cwd()) {
|
|
9
|
+
this._root = root;
|
|
10
|
+
}
|
|
11
|
+
get enable() {
|
|
12
|
+
return Boolean(this._options);
|
|
13
|
+
}
|
|
14
|
+
get options() {
|
|
15
|
+
return this._options;
|
|
16
|
+
}
|
|
17
|
+
get root() {
|
|
18
|
+
return this._root;
|
|
19
|
+
}
|
|
20
|
+
init(options, extraArgs) {
|
|
21
|
+
this._options = options;
|
|
22
|
+
}
|
|
23
|
+
setOptions(options) {
|
|
24
|
+
this._options = options;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class PKGJsonManager {
|
|
29
|
+
setPKGJson(pkg) {
|
|
30
|
+
this._pkg = pkg;
|
|
31
|
+
}
|
|
32
|
+
readPKGJson(root = process.cwd()) {
|
|
33
|
+
if (this._pkg) {
|
|
34
|
+
return this._pkg;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line no-restricted-globals
|
|
38
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
|
|
39
|
+
this._pkg = pkg;
|
|
40
|
+
return pkg;
|
|
41
|
+
}
|
|
42
|
+
catch (_err) {
|
|
43
|
+
try {
|
|
44
|
+
const pkg = finder.sync(root);
|
|
45
|
+
this._pkg = pkg;
|
|
46
|
+
return pkg;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
logger.error(err);
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
55
|
+
const pkg = this.readPKGJson(root);
|
|
56
|
+
return pkg?.['mf']?.type === MFModuleType.NPM
|
|
57
|
+
? MFModuleType.NPM
|
|
58
|
+
: MFModuleType.APP;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const LOCAL_BUILD_VERSION = 'local';
|
|
63
|
+
const UNKNOWN_MODULE_NAME = 'UNKNOWN';
|
|
64
|
+
|
|
65
|
+
function processFn(options, normalizeSimple, normalizeOptions, fn) {
|
|
66
|
+
const object = (obj) => {
|
|
67
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
68
|
+
if (typeof value === 'string') {
|
|
69
|
+
fn(key, normalizeSimple(value, key));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
fn(key, normalizeOptions(value, key));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const array = (items) => {
|
|
77
|
+
for (const item of items) {
|
|
78
|
+
if (typeof item === 'string') {
|
|
79
|
+
fn(item, normalizeSimple(item, item));
|
|
80
|
+
}
|
|
81
|
+
else if (item && typeof item === 'object') {
|
|
82
|
+
object(item);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new Error('Unexpected options format');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (!options) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
else if (Array.isArray(options)) {
|
|
93
|
+
array(options);
|
|
94
|
+
}
|
|
95
|
+
else if (typeof options === 'object') {
|
|
96
|
+
object(options);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error('Unexpected options format');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function parseOptions(options, normalizeSimple, normalizeOptions) {
|
|
103
|
+
const items = [];
|
|
104
|
+
processFn(options, normalizeSimple, normalizeOptions, (key, value) => {
|
|
105
|
+
items.push([key, value]);
|
|
106
|
+
});
|
|
107
|
+
return items;
|
|
108
|
+
}
|
|
109
|
+
function getBuildVersion(root) {
|
|
110
|
+
if (process.env['MF_BUILD_VERSION']) {
|
|
111
|
+
return process.env['MF_BUILD_VERSION'];
|
|
112
|
+
}
|
|
113
|
+
const pkg = new PKGJsonManager().readPKGJson(root);
|
|
114
|
+
if (pkg?.['version'] && typeof pkg['version'] === 'string') {
|
|
115
|
+
return pkg['version'];
|
|
116
|
+
}
|
|
117
|
+
return LOCAL_BUILD_VERSION;
|
|
118
|
+
}
|
|
119
|
+
function getBuildName() {
|
|
120
|
+
return process.env['MF_BUILD_NAME'];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
124
|
+
__proto__: null,
|
|
125
|
+
getBuildName: getBuildName,
|
|
126
|
+
getBuildVersion: getBuildVersion,
|
|
127
|
+
parseOptions: parseOptions
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
function normalizeExposeModuleName(exposeKey) {
|
|
131
|
+
const relativePath = path.relative('.', exposeKey);
|
|
132
|
+
if (!relativePath) {
|
|
133
|
+
return 'ExposeEntry';
|
|
134
|
+
}
|
|
135
|
+
return relativePath;
|
|
136
|
+
}
|
|
137
|
+
class ContainerManager extends BasicPluginOptionsManager {
|
|
138
|
+
get enable() {
|
|
139
|
+
return Boolean(this.options.name &&
|
|
140
|
+
this.options.exposes &&
|
|
141
|
+
(Array.isArray(this.options.exposes)
|
|
142
|
+
? this.options.exposes.length > 0
|
|
143
|
+
: Object.keys(this.options.exposes).length > 0));
|
|
144
|
+
}
|
|
145
|
+
get globalEntryName() {
|
|
146
|
+
const { name, library } = this.options;
|
|
147
|
+
if (library) {
|
|
148
|
+
if (typeof library.name === 'string') {
|
|
149
|
+
return library.name;
|
|
150
|
+
}
|
|
151
|
+
return name;
|
|
152
|
+
}
|
|
153
|
+
return name;
|
|
154
|
+
}
|
|
155
|
+
get containerPluginExposesOptions() {
|
|
156
|
+
const { exposes } = this.options;
|
|
157
|
+
const parsedOptions = parseOptions(exposes, (item, key) => ({
|
|
158
|
+
import: Array.isArray(item) ? item : [item],
|
|
159
|
+
name: generateExposeFilename(key, false),
|
|
160
|
+
}), (item, key) => ({
|
|
161
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
162
|
+
name: item.name || generateExposeFilename(key, false),
|
|
163
|
+
}));
|
|
164
|
+
return parsedOptions.reduce((sum, item) => {
|
|
165
|
+
const [exposeKey, exposeObj] = item;
|
|
166
|
+
sum[exposeKey] = exposeObj;
|
|
167
|
+
return sum;
|
|
168
|
+
}, {});
|
|
169
|
+
}
|
|
170
|
+
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
|
|
171
|
+
get fileExposeKeyMap() {
|
|
172
|
+
const parsedOptions = this._parseOptions();
|
|
173
|
+
return parsedOptions.reduce((sum, item) => {
|
|
174
|
+
const [exposeKey, exposeObject] = item;
|
|
175
|
+
exposeObject.import.forEach((exposeFile) => {
|
|
176
|
+
const exposeFileWithoutExt = exposeFile.replace(path.extname(exposeFile), '');
|
|
177
|
+
sum[exposeFileWithoutExt] ||= new Set();
|
|
178
|
+
sum[exposeFileWithoutExt].add(exposeKey);
|
|
179
|
+
});
|
|
180
|
+
return sum;
|
|
181
|
+
}, {});
|
|
182
|
+
}
|
|
183
|
+
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
|
|
184
|
+
get exposeFileNameImportMap() {
|
|
185
|
+
const { exposes } = this.options;
|
|
186
|
+
const parsedOptions = parseOptions(exposes, (item, key) => ({
|
|
187
|
+
import: Array.isArray(item) ? item : [item],
|
|
188
|
+
name: generateExposeFilename(key, false),
|
|
189
|
+
}), (item, key) => ({
|
|
190
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
191
|
+
name: item.name || generateExposeFilename(key, false),
|
|
192
|
+
}));
|
|
193
|
+
return parsedOptions.reduce((sum, item) => {
|
|
194
|
+
const [_exposeKey, exposeObj] = item;
|
|
195
|
+
const { name, import: importPath } = exposeObj;
|
|
196
|
+
sum[name] = importPath;
|
|
197
|
+
return sum;
|
|
198
|
+
}, {});
|
|
199
|
+
}
|
|
200
|
+
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
|
|
201
|
+
get exposeObject() {
|
|
202
|
+
const parsedOptions = this._parseOptions();
|
|
203
|
+
return parsedOptions.reduce((sum, item) => {
|
|
204
|
+
const [exposeKey, exposeObject] = item;
|
|
205
|
+
sum[exposeKey] = [];
|
|
206
|
+
exposeObject.import.forEach((item) => {
|
|
207
|
+
const relativePath = path.relative('.', item.replace(path.extname(item), ''));
|
|
208
|
+
sum[exposeKey].push(relativePath);
|
|
209
|
+
});
|
|
210
|
+
return sum;
|
|
211
|
+
}, {});
|
|
212
|
+
}
|
|
213
|
+
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
|
|
214
|
+
get exposeFiles() {
|
|
215
|
+
const parsedOptions = this._parseOptions();
|
|
216
|
+
return parsedOptions.reduce((sum, item) => {
|
|
217
|
+
const [_exposeKey, exposeObject] = item;
|
|
218
|
+
sum.push(...exposeObject.import);
|
|
219
|
+
return sum;
|
|
220
|
+
}, []);
|
|
221
|
+
}
|
|
222
|
+
get manifestModuleInfos() {
|
|
223
|
+
if (this._manifestModuleInfos) {
|
|
224
|
+
return this._manifestModuleInfos;
|
|
225
|
+
}
|
|
226
|
+
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
|
|
227
|
+
const parsedOptions = this._parseOptions();
|
|
228
|
+
this._manifestModuleInfos = parsedOptions.reduce((sum, item) => {
|
|
229
|
+
const [exposeKey, exposeObject] = item;
|
|
230
|
+
sum[exposeKey] = {
|
|
231
|
+
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
|
|
232
|
+
file: exposeObject.import,
|
|
233
|
+
};
|
|
234
|
+
return sum;
|
|
235
|
+
}, {});
|
|
236
|
+
return this._manifestModuleInfos;
|
|
237
|
+
}
|
|
238
|
+
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
|
|
239
|
+
get webpackEntry() {
|
|
240
|
+
return Object.values(this.manifestModuleInfos).reduce((sum, cur) => {
|
|
241
|
+
const entry = cur.name === 'ExposeEntry'
|
|
242
|
+
? 'index'
|
|
243
|
+
: cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
|
|
244
|
+
sum[entry] = cur.file;
|
|
245
|
+
return sum;
|
|
246
|
+
}, {});
|
|
247
|
+
}
|
|
248
|
+
_parseOptions() {
|
|
249
|
+
if (this._parsedOptions) {
|
|
250
|
+
return this._parsedOptions;
|
|
251
|
+
}
|
|
252
|
+
this._parsedOptions = parseOptions(this.options.exposes, (item) => ({
|
|
253
|
+
import: Array.isArray(item) ? item : [item],
|
|
254
|
+
name: undefined,
|
|
255
|
+
}), (item) => ({
|
|
256
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
257
|
+
name: undefined,
|
|
258
|
+
}));
|
|
259
|
+
return this._parsedOptions;
|
|
260
|
+
}
|
|
261
|
+
init(options) {
|
|
262
|
+
this.setOptions(options);
|
|
263
|
+
this.validate(options.name);
|
|
264
|
+
}
|
|
265
|
+
validate(name) {
|
|
266
|
+
if (!name) {
|
|
267
|
+
throw new Error(`container name can not be empty!`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getEntry(remoteObj) {
|
|
273
|
+
if (typeof remoteObj === 'string') {
|
|
274
|
+
return remoteObj;
|
|
275
|
+
}
|
|
276
|
+
if (typeof remoteObj.external === 'string') {
|
|
277
|
+
return remoteObj.external;
|
|
278
|
+
}
|
|
279
|
+
throw new Error('Not support "array" remote value yet!');
|
|
280
|
+
}
|
|
281
|
+
class RemoteManager extends BasicPluginOptionsManager {
|
|
282
|
+
constructor() {
|
|
283
|
+
super(...arguments);
|
|
284
|
+
this.normalizedOptions = {};
|
|
285
|
+
}
|
|
286
|
+
get enable() {
|
|
287
|
+
return Boolean(this.remotes &&
|
|
288
|
+
(Array.isArray(this.remotes)
|
|
289
|
+
? this.remotes.length > 0
|
|
290
|
+
: Object.keys(this.remotes).length > 0));
|
|
291
|
+
}
|
|
292
|
+
get statsRemoteWithEmptyUsedIn() {
|
|
293
|
+
const { name } = this.options;
|
|
294
|
+
return Object.keys(this.normalizedOptions).reduce((sum, cur) => {
|
|
295
|
+
const normalizedOption = this.normalizedOptions[cur];
|
|
296
|
+
let curObj;
|
|
297
|
+
if ('entry' in normalizedOption) {
|
|
298
|
+
curObj = {
|
|
299
|
+
entry: normalizedOption.entry,
|
|
300
|
+
alias: normalizedOption.alias,
|
|
301
|
+
moduleName: UNKNOWN_MODULE_NAME,
|
|
302
|
+
federationContainerName: normalizedOption.name,
|
|
303
|
+
consumingFederationContainerName: name,
|
|
304
|
+
usedIn: [UNKNOWN_MODULE_NAME],
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
curObj = {
|
|
309
|
+
alias: normalizedOption.alias,
|
|
310
|
+
moduleName: UNKNOWN_MODULE_NAME,
|
|
311
|
+
version: normalizedOption.version,
|
|
312
|
+
federationContainerName: normalizedOption.name,
|
|
313
|
+
consumingFederationContainerName: name,
|
|
314
|
+
usedIn: [UNKNOWN_MODULE_NAME],
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
sum.push(curObj);
|
|
318
|
+
return sum;
|
|
319
|
+
}, []);
|
|
320
|
+
}
|
|
321
|
+
// 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
|
|
322
|
+
// ↓↓↓
|
|
323
|
+
// {
|
|
324
|
+
// 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
|
|
325
|
+
// }
|
|
326
|
+
get dtsRemotes() {
|
|
327
|
+
return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias) => {
|
|
328
|
+
const remoteInfo = this.normalizedOptions[remoteAlias];
|
|
329
|
+
sum[remoteAlias] = composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
|
|
330
|
+
return sum;
|
|
331
|
+
}, {});
|
|
332
|
+
}
|
|
333
|
+
get remotes() {
|
|
334
|
+
return this.options.remotes;
|
|
335
|
+
}
|
|
336
|
+
// INFO: only support remoteType: script now
|
|
337
|
+
normalizeOptions(options = {}) {
|
|
338
|
+
this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias) => {
|
|
339
|
+
if (Array.isArray(options)) {
|
|
340
|
+
return sum;
|
|
341
|
+
}
|
|
342
|
+
const remoteInfo = options[remoteAlias];
|
|
343
|
+
if (Array.isArray(remoteInfo)) {
|
|
344
|
+
return sum;
|
|
345
|
+
}
|
|
346
|
+
let parsedOptions;
|
|
347
|
+
try {
|
|
348
|
+
parsedOptions = parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
|
|
349
|
+
}
|
|
350
|
+
catch (e) {
|
|
351
|
+
// noop
|
|
352
|
+
}
|
|
353
|
+
if (!parsedOptions) {
|
|
354
|
+
return sum;
|
|
355
|
+
}
|
|
356
|
+
sum[remoteAlias] = {
|
|
357
|
+
...parsedOptions,
|
|
358
|
+
alias: remoteAlias,
|
|
359
|
+
shareScope: typeof remoteInfo === 'object'
|
|
360
|
+
? remoteInfo.shareScope || 'default'
|
|
361
|
+
: 'default',
|
|
362
|
+
};
|
|
363
|
+
return sum;
|
|
364
|
+
}, {});
|
|
365
|
+
}
|
|
366
|
+
init(options) {
|
|
367
|
+
this.setOptions(options);
|
|
368
|
+
this.normalizeOptions(options.remotes);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// @ts-ignore this pkg miss types
|
|
373
|
+
class SharedManager extends BasicPluginOptionsManager {
|
|
374
|
+
constructor() {
|
|
375
|
+
super(...arguments);
|
|
376
|
+
this.normalizedOptions = {};
|
|
377
|
+
}
|
|
378
|
+
get enable() {
|
|
379
|
+
return Boolean(Object.keys(this.sharedPluginOptions.shared).length);
|
|
380
|
+
}
|
|
381
|
+
get sharedPluginOptions() {
|
|
382
|
+
const normalizedShared = this.normalizedOptions;
|
|
383
|
+
const shared = Object.keys(normalizedShared).reduce((sum, cur) => {
|
|
384
|
+
const { singleton, requiredVersion, version, eager, shareScope, import: sharedImport, } = normalizedShared[cur];
|
|
385
|
+
sum[cur] = {
|
|
386
|
+
singleton,
|
|
387
|
+
requiredVersion,
|
|
388
|
+
version,
|
|
389
|
+
eager,
|
|
390
|
+
shareScope,
|
|
391
|
+
import: sharedImport,
|
|
392
|
+
};
|
|
393
|
+
return sum;
|
|
394
|
+
}, {});
|
|
395
|
+
return {
|
|
396
|
+
shared,
|
|
397
|
+
shareScope: this.options.shareScope || 'default',
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
findPkg(name, shareConfig) {
|
|
401
|
+
try {
|
|
402
|
+
let pkgPath = '';
|
|
403
|
+
let depName = name;
|
|
404
|
+
if (shareConfig.import) {
|
|
405
|
+
if (path.isAbsolute(shareConfig.import)) {
|
|
406
|
+
pkgPath = shareConfig.import;
|
|
407
|
+
}
|
|
408
|
+
else if (shareConfig.import.startsWith('.')) {
|
|
409
|
+
pkgPath = path.resolve(this.root, shareConfig.import);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
if (shareConfig.packageName) {
|
|
414
|
+
depName = shareConfig.packageName;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
pkgPath = pkgPath || require.resolve(depName, { paths: [this.root] });
|
|
418
|
+
const pkgJsonPath = finder.sync(pkgPath);
|
|
419
|
+
return {
|
|
420
|
+
pkg: JSON.parse(fs$1.readFileSync(pkgJsonPath, 'utf-8')),
|
|
421
|
+
path: '',
|
|
422
|
+
pkgPath: '',
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
catch (err) {
|
|
426
|
+
return {
|
|
427
|
+
pkg: {},
|
|
428
|
+
path: '',
|
|
429
|
+
pkgPath: '',
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
transformSharedConfig(sharedConfig) {
|
|
434
|
+
const defaultSharedConfig = {
|
|
435
|
+
singleton: true,
|
|
436
|
+
requiredVersion: undefined,
|
|
437
|
+
shareScope: 'default',
|
|
438
|
+
};
|
|
439
|
+
return {
|
|
440
|
+
...defaultSharedConfig,
|
|
441
|
+
...sharedConfig,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
normalizeOptions(options) {
|
|
445
|
+
const normalizedShared = {};
|
|
446
|
+
const sharedOptions = parseOptions(options, (item, key) => {
|
|
447
|
+
if (typeof item !== 'string')
|
|
448
|
+
throw new Error('Unexpected array in shared');
|
|
449
|
+
const config = item === key || !isRequiredVersion(item)
|
|
450
|
+
? {
|
|
451
|
+
import: item,
|
|
452
|
+
}
|
|
453
|
+
: {
|
|
454
|
+
import: key,
|
|
455
|
+
requiredVersion: item,
|
|
456
|
+
};
|
|
457
|
+
return config;
|
|
458
|
+
}, (item) => item);
|
|
459
|
+
sharedOptions.forEach((item) => {
|
|
460
|
+
const [sharedName, sharedOptions] = item;
|
|
461
|
+
const pkgInfo = this.findPkg(sharedName, sharedOptions);
|
|
462
|
+
const sharedConfig = this.transformSharedConfig(sharedOptions);
|
|
463
|
+
normalizedShared[sharedName] = {
|
|
464
|
+
...sharedConfig,
|
|
465
|
+
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined'
|
|
466
|
+
? sharedConfig.requiredVersion
|
|
467
|
+
: `^${pkgInfo.pkg['version']}`,
|
|
468
|
+
name: sharedName,
|
|
469
|
+
version: pkgInfo.pkg['version'],
|
|
470
|
+
eager: Boolean(sharedConfig.eager),
|
|
471
|
+
};
|
|
472
|
+
});
|
|
473
|
+
this.normalizedOptions = normalizedShared;
|
|
474
|
+
}
|
|
475
|
+
init(options) {
|
|
476
|
+
this.setOptions(options);
|
|
477
|
+
this.normalizeOptions(options.shared);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
482
|
+
__proto__: null
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
export { BasicPluginOptionsManager, ContainerManager, PKGJsonManager, RemoteManager, SharedManager, UNKNOWN_MODULE_NAME, types, utils };
|
|
486
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/BasicPluginOptionsManager.ts","../../src/PKGJsonManager.ts","../../src/constant.ts","../../src/utils.ts","../../src/ContainerManager.ts","../../src/RemoteManager.ts","../../src/SharedManager.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["findPkg","fs"],"mappings":";;;;;;MAAa,yBAAyB,CAAA;AAIpC,IAAA,WAAA,CAAY,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAA;AAC9B,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;;AAGnB,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;;AAG/B,IAAA,IAAI,OAAO,GAAA;QACT,OAAO,IAAI,CAAC,QAAwB;;AAGtC,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK;;IAGnB,IAAI,CAAC,OAAU,EAAE,SAA+B,EAAA;AAC9C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAGzB,IAAA,UAAU,CAAC,OAAU,EAAA;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;AAE1B;;MCrBY,cAAc,CAAA;AAGzB,IAAA,UAAU,CAAC,GAAwB,EAAA;AACjC,QAAA,IAAI,CAAC,IAAI,GAAG,GAAG;;AAGjB,IAAA,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAA;AAC9B,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,CAAC,IAAI;;AAElB,QAAA,IAAI;;YAEF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAC5D;AACD,YAAA,IAAI,CAAC,IAAI,GAAG,GAAG;AAC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E,CAAA;AAClC,gBAAA,IAAI,EAAE,UAAU;AAChB,gBAAA,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/B,gBAAA,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;aACnC;AACH,SAAC,CAAC;AAEF,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB;;AAGlC,IAAA,IAAI,CACX,OAA6D,EAAA;AAE7D,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AACxB,QAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;;AAExC;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class BasicPluginOptionsManager<T> {
|
|
2
|
+
private _options?;
|
|
3
|
+
private _root;
|
|
4
|
+
constructor(root?: string);
|
|
5
|
+
get enable(): boolean;
|
|
6
|
+
get options(): T;
|
|
7
|
+
get root(): string;
|
|
8
|
+
init(options: T, extraArgs?: Record<string, any>): void;
|
|
9
|
+
setOptions(options: T): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { containerPlugin, ManifestModuleInfos, moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
import type { EntryObject } from 'webpack';
|
|
3
|
+
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
|
|
4
|
+
declare class ContainerManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
|
|
5
|
+
private _manifestModuleInfos?;
|
|
6
|
+
private _parsedOptions?;
|
|
7
|
+
get enable(): boolean;
|
|
8
|
+
get globalEntryName(): string | undefined;
|
|
9
|
+
get containerPluginExposesOptions(): containerPlugin.ContainerPluginOptions['exposes'];
|
|
10
|
+
get fileExposeKeyMap(): Record<string, Set<string>>;
|
|
11
|
+
get exposeFileNameImportMap(): Record<string, string[]>;
|
|
12
|
+
get exposeObject(): Record<string, string[]>;
|
|
13
|
+
get exposeFiles(): string[];
|
|
14
|
+
get manifestModuleInfos(): ManifestModuleInfos;
|
|
15
|
+
get webpackEntry(): EntryObject;
|
|
16
|
+
private _parseOptions;
|
|
17
|
+
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
18
|
+
validate(name?: string): void;
|
|
19
|
+
}
|
|
20
|
+
export { ContainerManager };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RemoteEntryInfo, StatsRemote, containerReferencePlugin, moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
|
|
3
|
+
interface NormalizedRemote {
|
|
4
|
+
[remoteName: string]: RemoteEntryInfo & {
|
|
5
|
+
alias: string;
|
|
6
|
+
shareScope: string | string[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
declare class RemoteManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
|
|
10
|
+
normalizedOptions: NormalizedRemote;
|
|
11
|
+
get enable(): boolean;
|
|
12
|
+
get statsRemoteWithEmptyUsedIn(): StatsRemote[];
|
|
13
|
+
get dtsRemotes(): Record<string, string>;
|
|
14
|
+
get remotes(): moduleFederationPlugin.ModuleFederationPluginOptions['remotes'];
|
|
15
|
+
normalizeOptions(options?: containerReferencePlugin.ContainerReferencePluginOptions['remotes']): void;
|
|
16
|
+
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
17
|
+
}
|
|
18
|
+
export { RemoteManager };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { moduleFederationPlugin, sharePlugin } from '@module-federation/sdk';
|
|
2
|
+
import { NormalizedSharedOptions } from './types';
|
|
3
|
+
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
|
|
4
|
+
type SharePluginOptions = ConstructorParameters<typeof sharePlugin.SharePlugin>[0];
|
|
5
|
+
declare class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
|
|
6
|
+
normalizedOptions: NormalizedSharedOptions;
|
|
7
|
+
get enable(): boolean;
|
|
8
|
+
get sharedPluginOptions(): SharePluginOptions;
|
|
9
|
+
findPkg(name: string, shareConfig: sharePlugin.SharedConfig): {
|
|
10
|
+
pkg: Record<string, any>;
|
|
11
|
+
path: string;
|
|
12
|
+
pkgPath: string;
|
|
13
|
+
};
|
|
14
|
+
transformSharedConfig(sharedConfig: sharePlugin.SharedConfig): sharePlugin.SharedConfig;
|
|
15
|
+
normalizeOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions['shared']): void;
|
|
16
|
+
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
17
|
+
}
|
|
18
|
+
export { SharedManager };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
|
|
2
|
+
export { ContainerManager } from './ContainerManager';
|
|
3
|
+
export { PKGJsonManager } from './PKGJsonManager';
|
|
4
|
+
export { RemoteManager } from './RemoteManager';
|
|
5
|
+
export { SharedManager } from './SharedManager';
|
|
6
|
+
export { UNKNOWN_MODULE_NAME } from './constant';
|
|
7
|
+
export * as utils from './utils';
|
|
8
|
+
export * as types from './types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebpackOptionsNormalized } from 'webpack';
|
|
2
|
+
import { sharePlugin } from '@module-federation/sdk';
|
|
3
|
+
export type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
|
|
4
|
+
export type EntryDescriptionNormalized = EntryStaticNormalized[keyof EntryStaticNormalized];
|
|
5
|
+
export type ContainerOptionsFormat<T> = (string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>;
|
|
6
|
+
export type NormalizeSimple<R> = (value: string | string[], key: string) => R;
|
|
7
|
+
export type NormalizeOptions<T, R> = (value: T, key: string) => R;
|
|
8
|
+
export type ProcessFN<R> = (key: string, normalizedOptions: R) => void;
|
|
9
|
+
export type ParsedContainerOptions<T> = [string, T][];
|
|
10
|
+
export type NormalizedSharedOption = {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
} & sharePlugin.SharedConfig;
|
|
14
|
+
export interface NormalizedSharedOptions {
|
|
15
|
+
[depName: string]: NormalizedSharedOption;
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContainerOptionsFormat, NormalizeSimple, NormalizeOptions, ParsedContainerOptions } from './types';
|
|
2
|
+
export declare function parseOptions<T, R>(options: ContainerOptionsFormat<T>, normalizeSimple: NormalizeSimple<R>, normalizeOptions: NormalizeOptions<T, R>): ParsedContainerOptions<R>;
|
|
3
|
+
export declare function getBuildVersion(root?: string): string;
|
|
4
|
+
export declare function getBuildName(): string | undefined;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@module-federation/managers",
|
|
3
|
+
"version": "0.0.0-docs-remove-invalid-lark-link-20251205062649",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Provide managers for helping handle mf data .",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Module Federation"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"author": "hanric <hanric.zhang@gmail.com>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/module-federation/core.git",
|
|
20
|
+
"directory": "packages/managers"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"main": "./dist/index.cjs.js",
|
|
24
|
+
"module": "./dist/index.esm.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"find-pkg": "2.0.0",
|
|
28
|
+
"fs-extra": "9.1.0",
|
|
29
|
+
"@module-federation/sdk": "0.0.0-docs-remove-invalid-lark-link-20251205062649"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"webpack": "5.94.0"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.esm.js",
|
|
38
|
+
"require": "./dist/index.cjs.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"typesVersions": {
|
|
42
|
+
"*": {
|
|
43
|
+
".": [
|
|
44
|
+
"./dist/index.d.ts"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|