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