@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.
@@ -0,0 +1,118 @@
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
+ PKGJsonManager: () => (/* binding */ PKGJsonManager)
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 "empathic/package"
65
+ const package_namespaceObject = require("empathic/package");
66
+ ;// CONCATENATED MODULE: external "fs"
67
+ const external_fs_namespaceObject = require("fs");
68
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
69
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
70
+ const sdk_namespaceObject = require("@module-federation/sdk");
71
+ ;// CONCATENATED MODULE: ./src/PKGJsonManager.ts
72
+
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 pkgPath = (0,package_namespaceObject.up)({
92
+ cwd: root
93
+ });
94
+ if (!pkgPath) {
95
+ return {};
96
+ }
97
+ const pkg = JSON.parse(external_fs_default().readFileSync(pkgPath, 'utf8'));
98
+ this._pkg = pkg;
99
+ return pkg;
100
+ } catch (err) {
101
+ sdk_namespaceObject.logger.error(err);
102
+ return {};
103
+ }
104
+ }
105
+ }
106
+ getExposeGarfishModuleType(root = process.cwd()) {
107
+ const pkg = this.readPKGJson(root);
108
+ return pkg?.['mf']?.type === sdk_namespaceObject.MFModuleType.NPM ? sdk_namespaceObject.MFModuleType.NPM : sdk_namespaceObject.MFModuleType.APP;
109
+ }
110
+ }
111
+
112
+ exports.PKGJsonManager = __webpack_exports__.PKGJsonManager;
113
+ for(var __rspack_i in __webpack_exports__) {
114
+ if(["PKGJsonManager"].indexOf(__rspack_i) === -1) {
115
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
116
+ }
117
+ }
118
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,50 @@
1
+ import path from "path";
2
+ import { up } from "empathic/package";
3
+ import fs from "fs";
4
+ import { MFModuleType, logger } from "@module-federation/sdk";
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ class PKGJsonManager {
15
+ setPKGJson(pkg) {
16
+ this._pkg = pkg;
17
+ }
18
+ readPKGJson(root = process.cwd()) {
19
+ if (this._pkg) {
20
+ return this._pkg;
21
+ }
22
+ try {
23
+ // eslint-disable-next-line no-restricted-globals
24
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
25
+ this._pkg = pkg;
26
+ return pkg;
27
+ } catch (_err) {
28
+ try {
29
+ const pkgPath = up({
30
+ cwd: root
31
+ });
32
+ if (!pkgPath) {
33
+ return {};
34
+ }
35
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
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
+ const pkg = this.readPKGJson(root);
46
+ return pkg?.['mf']?.type === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP;
47
+ }
48
+ }
49
+
50
+ export { PKGJsonManager };
@@ -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 { 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,162 @@
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
+ // ESM COMPAT FLAG
42
+ __webpack_require__.r(__webpack_exports__);
43
+
44
+ // EXPORTS
45
+ __webpack_require__.d(__webpack_exports__, {
46
+ RemoteManager: () => (/* binding */ RemoteManager)
47
+ });
48
+
49
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
50
+ const sdk_namespaceObject = require("@module-federation/sdk");
51
+ ;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
52
+ const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
53
+ ;// CONCATENATED MODULE: external "./constant.js"
54
+ const external_constant_js_namespaceObject = require("./constant.js");
55
+ ;// CONCATENATED MODULE: ./src/RemoteManager.ts
56
+
57
+
58
+
59
+ function getEntry(remoteObj) {
60
+ if (typeof remoteObj === 'string') {
61
+ return remoteObj;
62
+ }
63
+ if (typeof remoteObj.external === 'string') {
64
+ return remoteObj.external;
65
+ }
66
+ throw new Error('Not support "array" remote value yet!');
67
+ }
68
+ class RemoteManager extends external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager {
69
+ get enable() {
70
+ return Boolean(this.remotes && (Array.isArray(this.remotes) ? this.remotes.length > 0 : Object.keys(this.remotes).length > 0));
71
+ }
72
+ get statsRemoteWithEmptyUsedIn() {
73
+ const { name } = this.options;
74
+ return Object.keys(this.normalizedOptions).reduce((sum, cur)=>{
75
+ const normalizedOption = this.normalizedOptions[cur];
76
+ let curObj;
77
+ if ('entry' in normalizedOption) {
78
+ curObj = {
79
+ entry: normalizedOption.entry,
80
+ alias: normalizedOption.alias,
81
+ moduleName: external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME,
82
+ federationContainerName: normalizedOption.name,
83
+ consumingFederationContainerName: name,
84
+ usedIn: [
85
+ external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME
86
+ ]
87
+ };
88
+ } else {
89
+ curObj = {
90
+ alias: normalizedOption.alias,
91
+ moduleName: external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME,
92
+ version: normalizedOption.version,
93
+ federationContainerName: normalizedOption.name,
94
+ consumingFederationContainerName: name,
95
+ usedIn: [
96
+ external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME
97
+ ]
98
+ };
99
+ }
100
+ sum.push(curObj);
101
+ return sum;
102
+ }, []);
103
+ }
104
+ // 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
105
+ // ↓↓↓
106
+ // {
107
+ // 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
108
+ // }
109
+ get dtsRemotes() {
110
+ return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias)=>{
111
+ const remoteInfo = this.normalizedOptions[remoteAlias];
112
+ sum[remoteAlias] = (0,sdk_namespaceObject.composeKeyWithSeparator)(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
113
+ return sum;
114
+ }, {});
115
+ }
116
+ get remotes() {
117
+ return this.options.remotes;
118
+ }
119
+ // INFO: only support remoteType: script now
120
+ normalizeOptions(options = {}) {
121
+ this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias)=>{
122
+ if (Array.isArray(options)) {
123
+ return sum;
124
+ }
125
+ const remoteInfo = options[remoteAlias];
126
+ if (Array.isArray(remoteInfo)) {
127
+ return sum;
128
+ }
129
+ let parsedOptions;
130
+ try {
131
+ parsedOptions = (0,sdk_namespaceObject.parseEntry)(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
132
+ } catch (e) {
133
+ // noop
134
+ }
135
+ if (!parsedOptions) {
136
+ return sum;
137
+ }
138
+ sum[remoteAlias] = {
139
+ ...parsedOptions,
140
+ alias: remoteAlias,
141
+ shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default'
142
+ };
143
+ return sum;
144
+ }, {});
145
+ }
146
+ init(options) {
147
+ this.setOptions(options);
148
+ this.normalizeOptions(options.remotes);
149
+ }
150
+ constructor(...args){
151
+ super(...args), this.normalizedOptions = {};
152
+ }
153
+ }
154
+
155
+
156
+ exports.RemoteManager = __webpack_exports__.RemoteManager;
157
+ for(var __rspack_i in __webpack_exports__) {
158
+ if(["RemoteManager"].indexOf(__rspack_i) === -1) {
159
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
160
+ }
161
+ }
162
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,108 @@
1
+ import { composeKeyWithSeparator, parseEntry } from "@module-federation/sdk";
2
+ import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
3
+ import { UNKNOWN_MODULE_NAME } from "./constant.mjs";
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ function getEntry(remoteObj) {
12
+ if (typeof remoteObj === 'string') {
13
+ return remoteObj;
14
+ }
15
+ if (typeof remoteObj.external === 'string') {
16
+ return remoteObj.external;
17
+ }
18
+ throw new Error('Not support "array" remote value yet!');
19
+ }
20
+ class RemoteManager extends BasicPluginOptionsManager {
21
+ get enable() {
22
+ return Boolean(this.remotes && (Array.isArray(this.remotes) ? this.remotes.length > 0 : Object.keys(this.remotes).length > 0));
23
+ }
24
+ get statsRemoteWithEmptyUsedIn() {
25
+ const { name } = this.options;
26
+ return Object.keys(this.normalizedOptions).reduce((sum, cur)=>{
27
+ const normalizedOption = this.normalizedOptions[cur];
28
+ let curObj;
29
+ if ('entry' in normalizedOption) {
30
+ curObj = {
31
+ entry: normalizedOption.entry,
32
+ alias: normalizedOption.alias,
33
+ moduleName: UNKNOWN_MODULE_NAME,
34
+ federationContainerName: normalizedOption.name,
35
+ consumingFederationContainerName: name,
36
+ usedIn: [
37
+ UNKNOWN_MODULE_NAME
38
+ ]
39
+ };
40
+ } else {
41
+ curObj = {
42
+ alias: normalizedOption.alias,
43
+ moduleName: UNKNOWN_MODULE_NAME,
44
+ version: normalizedOption.version,
45
+ federationContainerName: normalizedOption.name,
46
+ consumingFederationContainerName: name,
47
+ usedIn: [
48
+ UNKNOWN_MODULE_NAME
49
+ ]
50
+ };
51
+ }
52
+ sum.push(curObj);
53
+ return sum;
54
+ }, []);
55
+ }
56
+ // 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
57
+ // ↓↓↓
58
+ // {
59
+ // 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
60
+ // }
61
+ get dtsRemotes() {
62
+ return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias)=>{
63
+ const remoteInfo = this.normalizedOptions[remoteAlias];
64
+ sum[remoteAlias] = composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
65
+ return sum;
66
+ }, {});
67
+ }
68
+ get remotes() {
69
+ return this.options.remotes;
70
+ }
71
+ // INFO: only support remoteType: script now
72
+ normalizeOptions(options = {}) {
73
+ this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias)=>{
74
+ if (Array.isArray(options)) {
75
+ return sum;
76
+ }
77
+ const remoteInfo = options[remoteAlias];
78
+ if (Array.isArray(remoteInfo)) {
79
+ return sum;
80
+ }
81
+ let parsedOptions;
82
+ try {
83
+ parsedOptions = parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
84
+ } catch (e) {
85
+ // noop
86
+ }
87
+ if (!parsedOptions) {
88
+ return sum;
89
+ }
90
+ sum[remoteAlias] = {
91
+ ...parsedOptions,
92
+ alias: remoteAlias,
93
+ shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default'
94
+ };
95
+ return sum;
96
+ }, {});
97
+ }
98
+ init(options) {
99
+ this.setOptions(options);
100
+ this.normalizeOptions(options.remotes);
101
+ }
102
+ constructor(...args){
103
+ super(...args), this.normalizedOptions = {};
104
+ }
105
+ }
106
+
107
+
108
+ 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
+ declare class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
5
+ normalizedOptions: NormalizedSharedOptions;
6
+ get enable(): boolean;
7
+ get sharedPluginOptions(): sharePlugin.SharePluginOptions;
8
+ findPkg(name: string, shareConfig: moduleFederationPlugin.SharedConfig): {
9
+ pkg: Record<string, any>;
10
+ path: string;
11
+ pkgPath: string;
12
+ };
13
+ get enableTreeShaking(): boolean;
14
+ transformSharedConfig(sharedConfig: moduleFederationPlugin.SharedConfig): moduleFederationPlugin.SharedConfig;
15
+ normalizeOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions['shared']): void;
16
+ init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
17
+ }
18
+ export { SharedManager };
@@ -0,0 +1,18 @@
1
+ import { moduleFederationPlugin, sharePlugin } from '@module-federation/sdk';
2
+ import { NormalizedSharedOptions } from './types';
3
+ import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
4
+ declare class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
5
+ normalizedOptions: NormalizedSharedOptions;
6
+ get enable(): boolean;
7
+ get sharedPluginOptions(): sharePlugin.SharePluginOptions;
8
+ findPkg(name: string, shareConfig: moduleFederationPlugin.SharedConfig): {
9
+ pkg: Record<string, any>;
10
+ path: string;
11
+ pkgPath: string;
12
+ };
13
+ get enableTreeShaking(): boolean;
14
+ transformSharedConfig(sharedConfig: moduleFederationPlugin.SharedConfig): moduleFederationPlugin.SharedConfig;
15
+ normalizeOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions['shared']): void;
16
+ init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
17
+ }
18
+ export { SharedManager };