@module-federation/managers 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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.
Files changed (45) hide show
  1. package/dist/BasicPluginOptionsManager.d.ts +10 -0
  2. package/dist/BasicPluginOptionsManager.js +73 -0
  3. package/dist/BasicPluginOptionsManager.mjs +22 -0
  4. package/dist/ContainerManager.d.ts +20 -0
  5. package/dist/ContainerManager.js +230 -0
  6. package/dist/ContainerManager.mjs +163 -0
  7. package/dist/PKGJsonManager.d.ts +6 -0
  8. package/dist/PKGJsonManager.js +116 -0
  9. package/dist/PKGJsonManager.mjs +48 -0
  10. package/dist/RemoteManager.d.ts +18 -0
  11. package/dist/RemoteManager.js +162 -0
  12. package/dist/RemoteManager.mjs +108 -0
  13. package/dist/SharedManager.d.mts +18 -0
  14. package/dist/{src/SharedManager.d.ts → SharedManager.d.ts} +4 -4
  15. package/dist/SharedManager.js +199 -0
  16. package/dist/SharedManager.mjs +131 -0
  17. package/dist/constant.d.ts +2 -0
  18. package/dist/constant.js +58 -0
  19. package/dist/constant.mjs +4 -0
  20. package/dist/findPackageJson.d.mts +1 -0
  21. package/dist/findPackageJson.d.ts +1 -0
  22. package/dist/findPackageJson.js +91 -0
  23. package/dist/findPackageJson.mjs +23 -0
  24. package/dist/index.d.ts +8 -1
  25. package/dist/index.js +95 -0
  26. package/dist/index.mjs +27 -0
  27. package/dist/types.d.mts +16 -0
  28. package/dist/{src/types.d.ts → types.d.ts} +2 -2
  29. package/dist/types.js +29 -0
  30. package/dist/types.mjs +3 -0
  31. package/dist/utils.d.ts +4 -0
  32. package/dist/utils.js +121 -0
  33. package/dist/utils.mjs +63 -0
  34. package/package.json +21 -10
  35. package/dist/index.cjs.js +0 -495
  36. package/dist/index.cjs.js.map +0 -1
  37. package/dist/index.esm.js +0 -486
  38. package/dist/index.esm.js.map +0 -1
  39. /package/dist/{src/BasicPluginOptionsManager.d.ts → BasicPluginOptionsManager.d.mts} +0 -0
  40. /package/dist/{src/ContainerManager.d.ts → ContainerManager.d.mts} +0 -0
  41. /package/dist/{src/PKGJsonManager.d.ts → PKGJsonManager.d.mts} +0 -0
  42. /package/dist/{src/RemoteManager.d.ts → RemoteManager.d.mts} +0 -0
  43. /package/dist/{src/constant.d.ts → constant.d.mts} +0 -0
  44. /package/dist/{src/index.d.ts → index.d.mts} +0 -0
  45. /package/dist/{src/utils.d.ts → utils.d.mts} +0 -0
@@ -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,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 };
@@ -0,0 +1,6 @@
1
+ export declare class PKGJsonManager {
2
+ private _pkg?;
3
+ setPKGJson(pkg: Record<string, any>): void;
4
+ readPKGJson(root?: string): Record<string, any>;
5
+ getExposeGarfishModuleType(root?: string): string;
6
+ }
@@ -0,0 +1,116 @@
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 "fs"
65
+ const external_fs_namespaceObject = require("fs");
66
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
67
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
68
+ const sdk_namespaceObject = require("@module-federation/sdk");
69
+ ;// CONCATENATED MODULE: external "./findPackageJson.js"
70
+ const external_findPackageJson_js_namespaceObject = require("./findPackageJson.js");
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,external_findPackageJson_js_namespaceObject.findPackageJson)(root);
92
+ if (!pkgPath) {
93
+ return {};
94
+ }
95
+ const pkg = JSON.parse(external_fs_default().readFileSync(pkgPath, 'utf8'));
96
+ this._pkg = pkg;
97
+ return pkg;
98
+ } catch (err) {
99
+ sdk_namespaceObject.logger.error(err);
100
+ return {};
101
+ }
102
+ }
103
+ }
104
+ getExposeGarfishModuleType(root = process.cwd()) {
105
+ const pkg = this.readPKGJson(root);
106
+ return pkg?.['mf']?.type === sdk_namespaceObject.MFModuleType.NPM ? sdk_namespaceObject.MFModuleType.NPM : sdk_namespaceObject.MFModuleType.APP;
107
+ }
108
+ }
109
+
110
+ exports.PKGJsonManager = __webpack_exports__.PKGJsonManager;
111
+ for(var __rspack_i in __webpack_exports__) {
112
+ if(["PKGJsonManager"].indexOf(__rspack_i) === -1) {
113
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
114
+ }
115
+ }
116
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,48 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { MFModuleType, logger } from "@module-federation/sdk";
4
+ import { findPackageJson } from "./findPackageJson.mjs";
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 = findPackageJson(root);
30
+ if (!pkgPath) {
31
+ return {};
32
+ }
33
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
34
+ this._pkg = pkg;
35
+ return pkg;
36
+ } catch (err) {
37
+ logger.error(err);
38
+ return {};
39
+ }
40
+ }
41
+ }
42
+ getExposeGarfishModuleType(root = process.cwd()) {
43
+ const pkg = this.readPKGJson(root);
44
+ return pkg?.['mf']?.type === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP;
45
+ }
46
+ }
47
+
48
+ export { PKGJsonManager };