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