@module-federation/managers 0.24.1 → 2.0.1
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/dist/BasicPluginOptionsManager.js +70 -0
- package/dist/BasicPluginOptionsManager.mjs +24 -0
- package/dist/ContainerManager.js +228 -0
- package/dist/ContainerManager.mjs +168 -0
- package/dist/PKGJsonManager.js +113 -0
- package/dist/PKGJsonManager.mjs +51 -0
- package/dist/RemoteManager.js +160 -0
- package/dist/RemoteManager.mjs +112 -0
- package/dist/SharedManager.js +196 -0
- package/dist/SharedManager.mjs +136 -0
- package/dist/constant.js +54 -0
- package/dist/constant.mjs +6 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +93 -0
- package/dist/index.mjs +36 -0
- package/dist/types.js +31 -0
- package/dist/types.mjs +4 -0
- package/dist/utils.js +119 -0
- package/dist/utils.mjs +66 -0
- package/package.json +13 -8
- package/dist/index.cjs.js +0 -499
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -490
- package/dist/index.esm.js.map +0 -1
- package/dist/src/index.d.ts +0 -8
- /package/dist/{src/BasicPluginOptionsManager.d.ts → BasicPluginOptionsManager.d.ts} +0 -0
- /package/dist/{src/ContainerManager.d.ts → ContainerManager.d.ts} +0 -0
- /package/dist/{src/PKGJsonManager.d.ts → PKGJsonManager.d.ts} +0 -0
- /package/dist/{src/RemoteManager.d.ts → RemoteManager.d.ts} +0 -0
- /package/dist/{src/SharedManager.d.ts → SharedManager.d.ts} +0 -0
- /package/dist/{src/constant.d.ts → constant.d.ts} +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
// webpack/runtime/define_property_getters
|
|
14
|
+
(() => {
|
|
15
|
+
__webpack_require__.d = (exports, definition) => {
|
|
16
|
+
for(var key in definition) {
|
|
17
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
18
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
23
|
+
// webpack/runtime/has_own_property
|
|
24
|
+
(() => {
|
|
25
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
26
|
+
})();
|
|
27
|
+
// webpack/runtime/make_namespace_object
|
|
28
|
+
(() => {
|
|
29
|
+
// define __esModule on exports
|
|
30
|
+
__webpack_require__.r = (exports) => {
|
|
31
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
32
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
/************************************************************************/
|
|
38
|
+
var __webpack_exports__ = {};
|
|
39
|
+
__webpack_require__.r(__webpack_exports__);
|
|
40
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
41
|
+
BasicPluginOptionsManager: () => (BasicPluginOptionsManager)
|
|
42
|
+
});
|
|
43
|
+
class BasicPluginOptionsManager {
|
|
44
|
+
get enable() {
|
|
45
|
+
return Boolean(this._options);
|
|
46
|
+
}
|
|
47
|
+
get options() {
|
|
48
|
+
return this._options;
|
|
49
|
+
}
|
|
50
|
+
get root() {
|
|
51
|
+
return this._root;
|
|
52
|
+
}
|
|
53
|
+
init(options, extraArgs) {
|
|
54
|
+
this._options = options;
|
|
55
|
+
}
|
|
56
|
+
setOptions(options) {
|
|
57
|
+
this._options = options;
|
|
58
|
+
}
|
|
59
|
+
constructor(root = process.cwd()){
|
|
60
|
+
this._root = root;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.BasicPluginOptionsManager = __webpack_exports__.BasicPluginOptionsManager;
|
|
65
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
66
|
+
if(["BasicPluginOptionsManager"].indexOf(__webpack_i__) === -1) {
|
|
67
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/BasicPluginOptionsManager.ts
|
|
3
|
+
class BasicPluginOptionsManager {
|
|
4
|
+
get enable() {
|
|
5
|
+
return Boolean(this._options);
|
|
6
|
+
}
|
|
7
|
+
get options() {
|
|
8
|
+
return this._options;
|
|
9
|
+
}
|
|
10
|
+
get root() {
|
|
11
|
+
return this._root;
|
|
12
|
+
}
|
|
13
|
+
init(options, extraArgs) {
|
|
14
|
+
this._options = options;
|
|
15
|
+
}
|
|
16
|
+
setOptions(options) {
|
|
17
|
+
this._options = options;
|
|
18
|
+
}
|
|
19
|
+
constructor(root = process.cwd()){
|
|
20
|
+
this._root = root;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { BasicPluginOptionsManager };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
// webpack/runtime/compat_get_default_export
|
|
14
|
+
(() => {
|
|
15
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
16
|
+
__webpack_require__.n = (module) => {
|
|
17
|
+
var getter = module && module.__esModule ?
|
|
18
|
+
() => (module['default']) :
|
|
19
|
+
() => (module);
|
|
20
|
+
__webpack_require__.d(getter, { a: getter });
|
|
21
|
+
return getter;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
})();
|
|
25
|
+
// webpack/runtime/define_property_getters
|
|
26
|
+
(() => {
|
|
27
|
+
__webpack_require__.d = (exports, definition) => {
|
|
28
|
+
for(var key in definition) {
|
|
29
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
30
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
// webpack/runtime/has_own_property
|
|
36
|
+
(() => {
|
|
37
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
38
|
+
})();
|
|
39
|
+
// webpack/runtime/make_namespace_object
|
|
40
|
+
(() => {
|
|
41
|
+
// define __esModule on exports
|
|
42
|
+
__webpack_require__.r = (exports) => {
|
|
43
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
44
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
45
|
+
}
|
|
46
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
/************************************************************************/
|
|
50
|
+
var __webpack_exports__ = {};
|
|
51
|
+
// ESM COMPAT FLAG
|
|
52
|
+
__webpack_require__.r(__webpack_exports__);
|
|
53
|
+
|
|
54
|
+
// EXPORTS
|
|
55
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
56
|
+
ContainerManager: () => (/* binding */ ContainerManager)
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
;// CONCATENATED MODULE: external "path"
|
|
60
|
+
const external_path_namespaceObject = require("path");
|
|
61
|
+
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
|
|
62
|
+
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
63
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
64
|
+
;// CONCATENATED MODULE: external "./utils.js"
|
|
65
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
66
|
+
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
|
|
67
|
+
const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
|
|
68
|
+
;// CONCATENATED MODULE: ./src/ContainerManager.ts
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function normalizeExposeModuleName(exposeKey) {
|
|
74
|
+
const relativePath = external_path_default().relative('.', exposeKey);
|
|
75
|
+
if (!relativePath) {
|
|
76
|
+
return 'ExposeEntry';
|
|
77
|
+
}
|
|
78
|
+
return relativePath;
|
|
79
|
+
}
|
|
80
|
+
class ContainerManager extends external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager {
|
|
81
|
+
get enable() {
|
|
82
|
+
return Boolean(this.options.name && this.options.exposes && (Array.isArray(this.options.exposes) ? this.options.exposes.length > 0 : Object.keys(this.options.exposes).length > 0));
|
|
83
|
+
}
|
|
84
|
+
get globalEntryName() {
|
|
85
|
+
const { name, library } = this.options;
|
|
86
|
+
if (library) {
|
|
87
|
+
if (typeof library.name === 'string') {
|
|
88
|
+
return library.name;
|
|
89
|
+
}
|
|
90
|
+
return name;
|
|
91
|
+
}
|
|
92
|
+
return name;
|
|
93
|
+
}
|
|
94
|
+
get containerPluginExposesOptions() {
|
|
95
|
+
const { exposes } = this.options;
|
|
96
|
+
const parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(exposes, (item, key)=>({
|
|
97
|
+
import: Array.isArray(item) ? item : [
|
|
98
|
+
item
|
|
99
|
+
],
|
|
100
|
+
name: (0,sdk_namespaceObject.generateExposeFilename)(key, false)
|
|
101
|
+
}), (item, key)=>({
|
|
102
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
103
|
+
item.import
|
|
104
|
+
],
|
|
105
|
+
name: item.name || (0,sdk_namespaceObject.generateExposeFilename)(key, false)
|
|
106
|
+
}));
|
|
107
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
108
|
+
const [exposeKey, exposeObj] = item;
|
|
109
|
+
sum[exposeKey] = exposeObj;
|
|
110
|
+
return sum;
|
|
111
|
+
}, {});
|
|
112
|
+
}
|
|
113
|
+
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
|
|
114
|
+
get fileExposeKeyMap() {
|
|
115
|
+
const parsedOptions = this._parseOptions();
|
|
116
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
117
|
+
const [exposeKey, exposeObject] = item;
|
|
118
|
+
exposeObject.import.forEach((exposeFile)=>{
|
|
119
|
+
const exposeFileWithoutExt = exposeFile.replace(external_path_default().extname(exposeFile), '');
|
|
120
|
+
sum[exposeFileWithoutExt] ||= new Set();
|
|
121
|
+
sum[exposeFileWithoutExt].add(exposeKey);
|
|
122
|
+
});
|
|
123
|
+
return sum;
|
|
124
|
+
}, {});
|
|
125
|
+
}
|
|
126
|
+
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
|
|
127
|
+
get exposeFileNameImportMap() {
|
|
128
|
+
const { exposes } = this.options;
|
|
129
|
+
const parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(exposes, (item, key)=>({
|
|
130
|
+
import: Array.isArray(item) ? item : [
|
|
131
|
+
item
|
|
132
|
+
],
|
|
133
|
+
name: (0,sdk_namespaceObject.generateExposeFilename)(key, false)
|
|
134
|
+
}), (item, key)=>({
|
|
135
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
136
|
+
item.import
|
|
137
|
+
],
|
|
138
|
+
name: item.name || (0,sdk_namespaceObject.generateExposeFilename)(key, false)
|
|
139
|
+
}));
|
|
140
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
141
|
+
const [_exposeKey, exposeObj] = item;
|
|
142
|
+
const { name, import: importPath } = exposeObj;
|
|
143
|
+
sum[name] = importPath;
|
|
144
|
+
return sum;
|
|
145
|
+
}, {});
|
|
146
|
+
}
|
|
147
|
+
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
|
|
148
|
+
get exposeObject() {
|
|
149
|
+
const parsedOptions = this._parseOptions();
|
|
150
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
151
|
+
const [exposeKey, exposeObject] = item;
|
|
152
|
+
sum[exposeKey] = [];
|
|
153
|
+
exposeObject.import.forEach((item)=>{
|
|
154
|
+
const relativePath = external_path_default().relative('.', item.replace(external_path_default().extname(item), ''));
|
|
155
|
+
sum[exposeKey].push(relativePath);
|
|
156
|
+
});
|
|
157
|
+
return sum;
|
|
158
|
+
}, {});
|
|
159
|
+
}
|
|
160
|
+
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
|
|
161
|
+
get exposeFiles() {
|
|
162
|
+
const parsedOptions = this._parseOptions();
|
|
163
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
164
|
+
const [_exposeKey, exposeObject] = item;
|
|
165
|
+
sum.push(...exposeObject.import);
|
|
166
|
+
return sum;
|
|
167
|
+
}, []);
|
|
168
|
+
}
|
|
169
|
+
get manifestModuleInfos() {
|
|
170
|
+
if (this._manifestModuleInfos) {
|
|
171
|
+
return this._manifestModuleInfos;
|
|
172
|
+
}
|
|
173
|
+
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
|
|
174
|
+
const parsedOptions = this._parseOptions();
|
|
175
|
+
this._manifestModuleInfos = parsedOptions.reduce((sum, item)=>{
|
|
176
|
+
const [exposeKey, exposeObject] = item;
|
|
177
|
+
sum[exposeKey] = {
|
|
178
|
+
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
|
|
179
|
+
file: exposeObject.import
|
|
180
|
+
};
|
|
181
|
+
return sum;
|
|
182
|
+
}, {});
|
|
183
|
+
return this._manifestModuleInfos;
|
|
184
|
+
}
|
|
185
|
+
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
|
|
186
|
+
get webpackEntry() {
|
|
187
|
+
return Object.values(this.manifestModuleInfos).reduce((sum, cur)=>{
|
|
188
|
+
const entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
|
|
189
|
+
sum[entry] = cur.file;
|
|
190
|
+
return sum;
|
|
191
|
+
}, {});
|
|
192
|
+
}
|
|
193
|
+
_parseOptions() {
|
|
194
|
+
if (this._parsedOptions) {
|
|
195
|
+
return this._parsedOptions;
|
|
196
|
+
}
|
|
197
|
+
this._parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(this.options.exposes, (item)=>({
|
|
198
|
+
import: Array.isArray(item) ? item : [
|
|
199
|
+
item
|
|
200
|
+
],
|
|
201
|
+
name: undefined
|
|
202
|
+
}), (item)=>({
|
|
203
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
204
|
+
item.import
|
|
205
|
+
],
|
|
206
|
+
name: undefined
|
|
207
|
+
}));
|
|
208
|
+
return this._parsedOptions;
|
|
209
|
+
}
|
|
210
|
+
init(options) {
|
|
211
|
+
this.setOptions(options);
|
|
212
|
+
this.validate(options.name);
|
|
213
|
+
}
|
|
214
|
+
validate(name) {
|
|
215
|
+
if (!name) {
|
|
216
|
+
throw new Error(`container name can not be empty!`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
exports.ContainerManager = __webpack_exports__.ContainerManager;
|
|
223
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
224
|
+
if(["ContainerManager"].indexOf(__webpack_i__) === -1) {
|
|
225
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { generateExposeFilename } from "@module-federation/sdk";
|
|
3
|
+
import { parseOptions } from "./utils.mjs";
|
|
4
|
+
import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "path"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "./utils.mjs"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.mjs"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: ./src/ContainerManager.ts
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function normalizeExposeModuleName(exposeKey) {
|
|
20
|
+
const relativePath = path.relative('.', exposeKey);
|
|
21
|
+
if (!relativePath) {
|
|
22
|
+
return 'ExposeEntry';
|
|
23
|
+
}
|
|
24
|
+
return relativePath;
|
|
25
|
+
}
|
|
26
|
+
class ContainerManager extends BasicPluginOptionsManager {
|
|
27
|
+
get enable() {
|
|
28
|
+
return Boolean(this.options.name && this.options.exposes && (Array.isArray(this.options.exposes) ? this.options.exposes.length > 0 : Object.keys(this.options.exposes).length > 0));
|
|
29
|
+
}
|
|
30
|
+
get globalEntryName() {
|
|
31
|
+
const { name, library } = this.options;
|
|
32
|
+
if (library) {
|
|
33
|
+
if (typeof library.name === 'string') {
|
|
34
|
+
return library.name;
|
|
35
|
+
}
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
return name;
|
|
39
|
+
}
|
|
40
|
+
get containerPluginExposesOptions() {
|
|
41
|
+
const { exposes } = this.options;
|
|
42
|
+
const parsedOptions = parseOptions(exposes, (item, key)=>({
|
|
43
|
+
import: Array.isArray(item) ? item : [
|
|
44
|
+
item
|
|
45
|
+
],
|
|
46
|
+
name: generateExposeFilename(key, false)
|
|
47
|
+
}), (item, key)=>({
|
|
48
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
49
|
+
item.import
|
|
50
|
+
],
|
|
51
|
+
name: item.name || generateExposeFilename(key, false)
|
|
52
|
+
}));
|
|
53
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
54
|
+
const [exposeKey, exposeObj] = item;
|
|
55
|
+
sum[exposeKey] = exposeObj;
|
|
56
|
+
return sum;
|
|
57
|
+
}, {});
|
|
58
|
+
}
|
|
59
|
+
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
|
|
60
|
+
get fileExposeKeyMap() {
|
|
61
|
+
const parsedOptions = this._parseOptions();
|
|
62
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
63
|
+
const [exposeKey, exposeObject] = item;
|
|
64
|
+
exposeObject.import.forEach((exposeFile)=>{
|
|
65
|
+
const exposeFileWithoutExt = exposeFile.replace(path.extname(exposeFile), '');
|
|
66
|
+
sum[exposeFileWithoutExt] ||= new Set();
|
|
67
|
+
sum[exposeFileWithoutExt].add(exposeKey);
|
|
68
|
+
});
|
|
69
|
+
return sum;
|
|
70
|
+
}, {});
|
|
71
|
+
}
|
|
72
|
+
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
|
|
73
|
+
get exposeFileNameImportMap() {
|
|
74
|
+
const { exposes } = this.options;
|
|
75
|
+
const parsedOptions = parseOptions(exposes, (item, key)=>({
|
|
76
|
+
import: Array.isArray(item) ? item : [
|
|
77
|
+
item
|
|
78
|
+
],
|
|
79
|
+
name: generateExposeFilename(key, false)
|
|
80
|
+
}), (item, key)=>({
|
|
81
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
82
|
+
item.import
|
|
83
|
+
],
|
|
84
|
+
name: item.name || generateExposeFilename(key, false)
|
|
85
|
+
}));
|
|
86
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
87
|
+
const [_exposeKey, exposeObj] = item;
|
|
88
|
+
const { name, import: importPath } = exposeObj;
|
|
89
|
+
sum[name] = importPath;
|
|
90
|
+
return sum;
|
|
91
|
+
}, {});
|
|
92
|
+
}
|
|
93
|
+
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
|
|
94
|
+
get exposeObject() {
|
|
95
|
+
const parsedOptions = this._parseOptions();
|
|
96
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
97
|
+
const [exposeKey, exposeObject] = item;
|
|
98
|
+
sum[exposeKey] = [];
|
|
99
|
+
exposeObject.import.forEach((item)=>{
|
|
100
|
+
const relativePath = path.relative('.', item.replace(path.extname(item), ''));
|
|
101
|
+
sum[exposeKey].push(relativePath);
|
|
102
|
+
});
|
|
103
|
+
return sum;
|
|
104
|
+
}, {});
|
|
105
|
+
}
|
|
106
|
+
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
|
|
107
|
+
get exposeFiles() {
|
|
108
|
+
const parsedOptions = this._parseOptions();
|
|
109
|
+
return parsedOptions.reduce((sum, item)=>{
|
|
110
|
+
const [_exposeKey, exposeObject] = item;
|
|
111
|
+
sum.push(...exposeObject.import);
|
|
112
|
+
return sum;
|
|
113
|
+
}, []);
|
|
114
|
+
}
|
|
115
|
+
get manifestModuleInfos() {
|
|
116
|
+
if (this._manifestModuleInfos) {
|
|
117
|
+
return this._manifestModuleInfos;
|
|
118
|
+
}
|
|
119
|
+
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
|
|
120
|
+
const parsedOptions = this._parseOptions();
|
|
121
|
+
this._manifestModuleInfos = parsedOptions.reduce((sum, item)=>{
|
|
122
|
+
const [exposeKey, exposeObject] = item;
|
|
123
|
+
sum[exposeKey] = {
|
|
124
|
+
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
|
|
125
|
+
file: exposeObject.import
|
|
126
|
+
};
|
|
127
|
+
return sum;
|
|
128
|
+
}, {});
|
|
129
|
+
return this._manifestModuleInfos;
|
|
130
|
+
}
|
|
131
|
+
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
|
|
132
|
+
get webpackEntry() {
|
|
133
|
+
return Object.values(this.manifestModuleInfos).reduce((sum, cur)=>{
|
|
134
|
+
const entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
|
|
135
|
+
sum[entry] = cur.file;
|
|
136
|
+
return sum;
|
|
137
|
+
}, {});
|
|
138
|
+
}
|
|
139
|
+
_parseOptions() {
|
|
140
|
+
if (this._parsedOptions) {
|
|
141
|
+
return this._parsedOptions;
|
|
142
|
+
}
|
|
143
|
+
this._parsedOptions = parseOptions(this.options.exposes, (item)=>({
|
|
144
|
+
import: Array.isArray(item) ? item : [
|
|
145
|
+
item
|
|
146
|
+
],
|
|
147
|
+
name: undefined
|
|
148
|
+
}), (item)=>({
|
|
149
|
+
import: Array.isArray(item.import) ? item.import : [
|
|
150
|
+
item.import
|
|
151
|
+
],
|
|
152
|
+
name: undefined
|
|
153
|
+
}));
|
|
154
|
+
return this._parsedOptions;
|
|
155
|
+
}
|
|
156
|
+
init(options) {
|
|
157
|
+
this.setOptions(options);
|
|
158
|
+
this.validate(options.name);
|
|
159
|
+
}
|
|
160
|
+
validate(name) {
|
|
161
|
+
if (!name) {
|
|
162
|
+
throw new Error(`container name can not be empty!`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
export { ContainerManager };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
// webpack/runtime/compat_get_default_export
|
|
14
|
+
(() => {
|
|
15
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
16
|
+
__webpack_require__.n = (module) => {
|
|
17
|
+
var getter = module && module.__esModule ?
|
|
18
|
+
() => (module['default']) :
|
|
19
|
+
() => (module);
|
|
20
|
+
__webpack_require__.d(getter, { a: getter });
|
|
21
|
+
return getter;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
})();
|
|
25
|
+
// webpack/runtime/define_property_getters
|
|
26
|
+
(() => {
|
|
27
|
+
__webpack_require__.d = (exports, definition) => {
|
|
28
|
+
for(var key in definition) {
|
|
29
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
30
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
// webpack/runtime/has_own_property
|
|
36
|
+
(() => {
|
|
37
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
38
|
+
})();
|
|
39
|
+
// webpack/runtime/make_namespace_object
|
|
40
|
+
(() => {
|
|
41
|
+
// define __esModule on exports
|
|
42
|
+
__webpack_require__.r = (exports) => {
|
|
43
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
44
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
45
|
+
}
|
|
46
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
/************************************************************************/
|
|
50
|
+
var __webpack_exports__ = {};
|
|
51
|
+
// ESM COMPAT FLAG
|
|
52
|
+
__webpack_require__.r(__webpack_exports__);
|
|
53
|
+
|
|
54
|
+
// EXPORTS
|
|
55
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
56
|
+
PKGJsonManager: () => (/* binding */ PKGJsonManager)
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
;// CONCATENATED MODULE: external "path"
|
|
60
|
+
const external_path_namespaceObject = require("path");
|
|
61
|
+
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
|
|
62
|
+
;// CONCATENATED MODULE: external "find-pkg"
|
|
63
|
+
const external_find_pkg_namespaceObject = require("find-pkg");
|
|
64
|
+
var external_find_pkg_default = /*#__PURE__*/__webpack_require__.n(external_find_pkg_namespaceObject);
|
|
65
|
+
;// CONCATENATED MODULE: external "fs"
|
|
66
|
+
const external_fs_namespaceObject = require("fs");
|
|
67
|
+
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
|
|
68
|
+
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
69
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
70
|
+
;// CONCATENATED MODULE: ./src/PKGJsonManager.ts
|
|
71
|
+
|
|
72
|
+
// @ts-ignore this pkg miss types
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class PKGJsonManager {
|
|
77
|
+
setPKGJson(pkg) {
|
|
78
|
+
this._pkg = pkg;
|
|
79
|
+
}
|
|
80
|
+
readPKGJson(root = process.cwd()) {
|
|
81
|
+
if (this._pkg) {
|
|
82
|
+
return this._pkg;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
// eslint-disable-next-line no-restricted-globals
|
|
86
|
+
const pkg = JSON.parse(external_fs_default().readFileSync(external_path_default().resolve(root, 'package.json'), 'utf8'));
|
|
87
|
+
this._pkg = pkg;
|
|
88
|
+
return pkg;
|
|
89
|
+
} catch (_err) {
|
|
90
|
+
try {
|
|
91
|
+
const pkg = external_find_pkg_default().sync(root);
|
|
92
|
+
this._pkg = pkg;
|
|
93
|
+
return pkg;
|
|
94
|
+
} catch (err) {
|
|
95
|
+
sdk_namespaceObject.logger.error(err);
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
101
|
+
var _pkg_mf;
|
|
102
|
+
const pkg = this.readPKGJson(root);
|
|
103
|
+
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg['mf']) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === sdk_namespaceObject.MFModuleType.NPM ? sdk_namespaceObject.MFModuleType.NPM : sdk_namespaceObject.MFModuleType.APP;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exports.PKGJsonManager = __webpack_exports__.PKGJsonManager;
|
|
108
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
109
|
+
if(["PKGJsonManager"].indexOf(__webpack_i__) === -1) {
|
|
110
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import find_pkg from "find-pkg";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { MFModuleType, logger } from "@module-federation/sdk";
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "path"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "find-pkg"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "fs"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: ./src/PKGJsonManager.ts
|
|
15
|
+
|
|
16
|
+
// @ts-ignore this pkg miss types
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PKGJsonManager {
|
|
21
|
+
setPKGJson(pkg) {
|
|
22
|
+
this._pkg = pkg;
|
|
23
|
+
}
|
|
24
|
+
readPKGJson(root = process.cwd()) {
|
|
25
|
+
if (this._pkg) {
|
|
26
|
+
return this._pkg;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
// eslint-disable-next-line no-restricted-globals
|
|
30
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
|
|
31
|
+
this._pkg = pkg;
|
|
32
|
+
return pkg;
|
|
33
|
+
} catch (_err) {
|
|
34
|
+
try {
|
|
35
|
+
const pkg = find_pkg.sync(root);
|
|
36
|
+
this._pkg = pkg;
|
|
37
|
+
return pkg;
|
|
38
|
+
} catch (err) {
|
|
39
|
+
logger.error(err);
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
45
|
+
var _pkg_mf;
|
|
46
|
+
const pkg = this.readPKGJson(root);
|
|
47
|
+
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg['mf']) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { PKGJsonManager };
|