@module-federation/manifest 2.0.0 → 2.1.0

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,161 @@
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
+ ManifestManager: () => (/* binding */ ManifestManager)
57
+ });
58
+
59
+ ;// CONCATENATED MODULE: external "chalk"
60
+ const external_chalk_namespaceObject = require("chalk");
61
+ var external_chalk_default = /*#__PURE__*/__webpack_require__.n(external_chalk_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 "./logger.js"
67
+ const external_logger_js_namespaceObject = require("./logger.js");
68
+ var external_logger_js_default = /*#__PURE__*/__webpack_require__.n(external_logger_js_namespaceObject);
69
+ ;// CONCATENATED MODULE: ./src/ManifestManager.ts
70
+
71
+
72
+
73
+
74
+ class ManifestManager {
75
+ init(options) {
76
+ this._options = options;
77
+ }
78
+ get fileName() {
79
+ return (0,sdk_namespaceObject.getManifestFileName)(this._options.manifest).manifestFileName;
80
+ }
81
+ updateManifest(options) {
82
+ const manifest = this.generateManifest(options);
83
+ return manifest;
84
+ }
85
+ generateManifest(options) {
86
+ const { publicPath, stats, compiler } = options;
87
+ // Initialize manifest with required properties from stats
88
+ const { id, name, metaData } = stats;
89
+ if (metaData.buildInfo) {
90
+ 'target' in metaData.buildInfo && delete metaData.buildInfo.target;
91
+ 'plugins' in metaData.buildInfo && delete metaData.buildInfo.plugins;
92
+ }
93
+ const manifest = {
94
+ id,
95
+ name,
96
+ metaData,
97
+ shared: [],
98
+ remotes: [],
99
+ exposes: []
100
+ };
101
+ manifest.exposes = stats.exposes.reduce((sum, cur)=>{
102
+ const expose = {
103
+ id: cur.id,
104
+ name: cur.name,
105
+ assets: cur.assets,
106
+ path: cur.path
107
+ };
108
+ sum.push(expose);
109
+ return sum;
110
+ }, []);
111
+ manifest.shared = stats.shared.reduce((sum, cur)=>{
112
+ const shared = {
113
+ id: cur.id,
114
+ name: cur.name,
115
+ version: cur.version,
116
+ singleton: cur.singleton,
117
+ requiredVersion: cur.requiredVersion,
118
+ hash: cur.hash,
119
+ assets: cur.assets,
120
+ fallback: cur.fallback,
121
+ fallbackName: cur.fallbackName,
122
+ fallbackType: cur.fallbackType
123
+ };
124
+ sum.push(shared);
125
+ return sum;
126
+ }, []);
127
+ manifest.remotes = stats.remotes.reduce((sum, cur)=>{
128
+ // @ts-ignore version/entry will be added as follow
129
+ const remote = {
130
+ federationContainerName: cur.federationContainerName,
131
+ moduleName: cur.moduleName,
132
+ alias: cur.alias
133
+ };
134
+ if ('entry' in cur) {
135
+ // @ts-ignore
136
+ remote.entry = cur.entry;
137
+ } else if ('version' in cur) {
138
+ // @ts-ignore
139
+ remote.entry = cur.version;
140
+ }
141
+ sum.push(remote);
142
+ return sum;
143
+ }, []);
144
+ if ((0,external_utils_js_namespaceObject.isDev)() && (process.env['MF_SSR_PRJ'] ? compiler.options.target !== 'async-node' : true)) {
145
+ external_logger_js_default().info(`Manifest Link: ${external_chalk_default().cyan(`${publicPath === 'auto' ? '{auto}/' : publicPath}${this.fileName}`)} `);
146
+ }
147
+ return manifest;
148
+ }
149
+ constructor(){
150
+ this._options = {};
151
+ }
152
+ }
153
+
154
+
155
+ exports.ManifestManager = __webpack_exports__.ManifestManager;
156
+ for(var __webpack_i__ in __webpack_exports__) {
157
+ if(["ManifestManager"].indexOf(__webpack_i__) === -1) {
158
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
159
+ }
160
+ }
161
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,100 @@
1
+ import chalk from "chalk";
2
+ import { getManifestFileName } from "@module-federation/sdk";
3
+ import { isDev } from "./utils.mjs";
4
+ import logger from "./logger.mjs";
5
+
6
+ ;// CONCATENATED MODULE: external "chalk"
7
+
8
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
9
+
10
+ ;// CONCATENATED MODULE: external "./utils.mjs"
11
+
12
+ ;// CONCATENATED MODULE: external "./logger.mjs"
13
+
14
+ ;// CONCATENATED MODULE: ./src/ManifestManager.ts
15
+
16
+
17
+
18
+
19
+ class ManifestManager {
20
+ init(options) {
21
+ this._options = options;
22
+ }
23
+ get fileName() {
24
+ return getManifestFileName(this._options.manifest).manifestFileName;
25
+ }
26
+ updateManifest(options) {
27
+ const manifest = this.generateManifest(options);
28
+ return manifest;
29
+ }
30
+ generateManifest(options) {
31
+ const { publicPath, stats, compiler } = options;
32
+ // Initialize manifest with required properties from stats
33
+ const { id, name, metaData } = stats;
34
+ if (metaData.buildInfo) {
35
+ 'target' in metaData.buildInfo && delete metaData.buildInfo.target;
36
+ 'plugins' in metaData.buildInfo && delete metaData.buildInfo.plugins;
37
+ }
38
+ const manifest = {
39
+ id,
40
+ name,
41
+ metaData,
42
+ shared: [],
43
+ remotes: [],
44
+ exposes: []
45
+ };
46
+ manifest.exposes = stats.exposes.reduce((sum, cur)=>{
47
+ const expose = {
48
+ id: cur.id,
49
+ name: cur.name,
50
+ assets: cur.assets,
51
+ path: cur.path
52
+ };
53
+ sum.push(expose);
54
+ return sum;
55
+ }, []);
56
+ manifest.shared = stats.shared.reduce((sum, cur)=>{
57
+ const shared = {
58
+ id: cur.id,
59
+ name: cur.name,
60
+ version: cur.version,
61
+ singleton: cur.singleton,
62
+ requiredVersion: cur.requiredVersion,
63
+ hash: cur.hash,
64
+ assets: cur.assets,
65
+ fallback: cur.fallback,
66
+ fallbackName: cur.fallbackName,
67
+ fallbackType: cur.fallbackType
68
+ };
69
+ sum.push(shared);
70
+ return sum;
71
+ }, []);
72
+ manifest.remotes = stats.remotes.reduce((sum, cur)=>{
73
+ // @ts-ignore version/entry will be added as follow
74
+ const remote = {
75
+ federationContainerName: cur.federationContainerName,
76
+ moduleName: cur.moduleName,
77
+ alias: cur.alias
78
+ };
79
+ if ('entry' in cur) {
80
+ // @ts-ignore
81
+ remote.entry = cur.entry;
82
+ } else if ('version' in cur) {
83
+ // @ts-ignore
84
+ remote.entry = cur.version;
85
+ }
86
+ sum.push(remote);
87
+ return sum;
88
+ }, []);
89
+ if (isDev() && (process.env['MF_SSR_PRJ'] ? compiler.options.target !== 'async-node' : true)) {
90
+ logger.info(`Manifest Link: ${chalk.cyan(`${publicPath === 'auto' ? '{auto}/' : publicPath}${this.fileName}`)} `);
91
+ }
92
+ return manifest;
93
+ }
94
+ constructor(){
95
+ this._options = {};
96
+ }
97
+ }
98
+
99
+
100
+ export { ManifestManager };
@@ -1,5 +1,5 @@
1
1
  import { StatsExpose, StatsRemote, StatsShared, moduleFederationPlugin } from '@module-federation/sdk';
2
- import type { StatsModule } from 'webpack';
2
+ import type { StatsModule } from '../../../webpack/lib/stats/DefaultStatsFactoryPlugin.d';
3
3
  import type managerTypes from '@module-federation/managers';
4
4
  export declare const getExposeName: (exposeKey: string) => string;
5
5
  export declare function getExposeItem({ exposeKey, name, file, }: {