@bleedingdev/mf-manifest 2.9.1

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,106 @@
1
+ import { bindLoggerToCompiler } from "@module-federation/sdk";
2
+ import { ManifestManager } from "./ManifestManager.mjs";
3
+ import { StatsManager } from "./StatsManager.mjs";
4
+ import { PLUGIN_IDENTIFIER } from "./constants.mjs";
5
+ import logger from "./logger.mjs";
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ class StatsPlugin {
18
+ apply(compiler) {
19
+ bindLoggerToCompiler(logger, compiler, PLUGIN_IDENTIFIER);
20
+ if (!this._enable) {
21
+ return;
22
+ }
23
+ const res = this._statsManager.validate(compiler);
24
+ if (!res) {
25
+ return;
26
+ }
27
+ compiler.hooks.thisCompilation.tap('generateStats', (compilation)=>{
28
+ compilation.hooks.processAssets.tapPromise({
29
+ name: 'generateStats',
30
+ // @ts-ignore use runtime variable in case peer dep not installed
31
+ stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
32
+ }, async ()=>{
33
+ if (this._options.manifest !== false) {
34
+ const existedStats = compilation.getAsset(this._statsManager.fileName);
35
+ // new rspack should hit
36
+ if (existedStats) {
37
+ let updatedStats = this._statsManager.updateStats(JSON.parse(existedStats.source.source().toString()), compiler);
38
+ if (typeof this._options.manifest === 'object' && this._options.manifest.additionalData) {
39
+ updatedStats = await this._options.manifest.additionalData({
40
+ stats: updatedStats,
41
+ compiler,
42
+ compilation,
43
+ bundler: this._bundler
44
+ }) || updatedStats;
45
+ }
46
+ compilation.updateAsset(this._statsManager.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(updatedStats, null, 2)));
47
+ const updatedManifest = this._manifestManager.updateManifest({
48
+ compilation,
49
+ stats: updatedStats,
50
+ publicPath: this._statsManager.getPublicPath(compiler),
51
+ compiler,
52
+ bundler: this._bundler
53
+ });
54
+ const source = new compiler.webpack.sources.RawSource(JSON.stringify(updatedManifest, null, 2));
55
+ compilation.updateAsset(this._manifestManager.fileName, source);
56
+ return;
57
+ }
58
+ // webpack + legacy rspack
59
+ let stats = await this._statsManager.generateStats(compiler, compilation);
60
+ if (typeof this._options.manifest === 'object' && this._options.manifest.additionalData) {
61
+ stats = await this._options.manifest.additionalData({
62
+ stats,
63
+ compiler,
64
+ compilation,
65
+ bundler: this._bundler
66
+ }) || stats;
67
+ }
68
+ const manifest = await this._manifestManager.generateManifest({
69
+ compilation,
70
+ stats: stats,
71
+ publicPath: this._statsManager.getPublicPath(compiler),
72
+ compiler,
73
+ bundler: this._bundler
74
+ });
75
+ compilation.emitAsset(this._statsManager.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
76
+ compilation.emitAsset(this._manifestManager.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(manifest, null, 2)));
77
+ }
78
+ });
79
+ });
80
+ }
81
+ constructor(options, { pluginVersion, bundler }){
82
+ this.name = 'StatsPlugin';
83
+ this._options = {};
84
+ this._statsManager = new StatsManager();
85
+ this._manifestManager = new ManifestManager();
86
+ this._enable = true;
87
+ this._bundler = 'webpack';
88
+ try {
89
+ this._options = options;
90
+ this._bundler = bundler;
91
+ this._statsManager.init(this._options, {
92
+ pluginVersion,
93
+ bundler
94
+ });
95
+ this._manifestManager.init(this._options);
96
+ } catch (err) {
97
+ if (err instanceof Error) {
98
+ err.message = `[ ${PLUGIN_IDENTIFIER} ]: Manifest will not generate, because: ${err.message}`;
99
+ }
100
+ logger.error(err);
101
+ this._enable = false;
102
+ }
103
+ }
104
+ }
105
+
106
+ export { StatsPlugin };
@@ -0,0 +1,2 @@
1
+ export declare const PLUGIN_IDENTIFIER = "Module Federation Manifest Plugin";
2
+ export declare const HOT_UPDATE_SUFFIX = ".hot-update";
@@ -0,0 +1,58 @@
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
+ const PLUGIN_IDENTIFIER = 'Module Federation Manifest Plugin';
43
+ const HOT_UPDATE_SUFFIX = '.hot-update';
44
+
45
+ __webpack_require__.d(__webpack_exports__, {
46
+ }, {
47
+ HOT_UPDATE_SUFFIX: HOT_UPDATE_SUFFIX,
48
+ PLUGIN_IDENTIFIER: PLUGIN_IDENTIFIER
49
+ });
50
+
51
+ exports.HOT_UPDATE_SUFFIX = __webpack_exports__.HOT_UPDATE_SUFFIX;
52
+ exports.PLUGIN_IDENTIFIER = __webpack_exports__.PLUGIN_IDENTIFIER;
53
+ for(var __rspack_i in __webpack_exports__) {
54
+ if(["HOT_UPDATE_SUFFIX","PLUGIN_IDENTIFIER"].indexOf(__rspack_i) === -1) {
55
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ }
57
+ }
58
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,4 @@
1
+ const PLUGIN_IDENTIFIER = 'Module Federation Manifest Plugin';
2
+ const HOT_UPDATE_SUFFIX = '.hot-update';
3
+
4
+ export { HOT_UPDATE_SUFFIX, PLUGIN_IDENTIFIER };
@@ -0,0 +1,4 @@
1
+ export { StatsPlugin } from './StatsPlugin';
2
+ export { ManifestManager } from './ManifestManager';
3
+ export { StatsManager } from './StatsManager';
4
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,128 @@
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
+ var __webpack_modules__ = ({
10
+ "./ManifestManager"(module) {
11
+ module.exports = require("./ManifestManager.js");
12
+
13
+ },
14
+ "./StatsManager"(module) {
15
+ module.exports = require("./StatsManager.js");
16
+
17
+ },
18
+ "./StatsPlugin"(module) {
19
+ module.exports = require("./StatsPlugin.js");
20
+
21
+ },
22
+ "./types"(module) {
23
+ module.exports = require("./types.js");
24
+
25
+ },
26
+
27
+ });
28
+ // The module cache
29
+ var __webpack_module_cache__ = {};
30
+
31
+ // The require function
32
+ function __webpack_require__(moduleId) {
33
+
34
+ // Check if module is in cache
35
+ var cachedModule = __webpack_module_cache__[moduleId];
36
+ if (cachedModule !== undefined) {
37
+ return cachedModule.exports;
38
+ }
39
+ // Create a new module (and put it into the cache)
40
+ var module = (__webpack_module_cache__[moduleId] = {
41
+ exports: {}
42
+ });
43
+ // Execute the module function
44
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
45
+
46
+ // Return the exports of the module
47
+ return module.exports;
48
+
49
+ }
50
+
51
+ // webpack/runtime/compat_get_default_export
52
+ (() => {
53
+ // getDefaultExport function for compatibility with non-ESM modules
54
+ __webpack_require__.n = (module) => {
55
+ var getter = module && module.__esModule ?
56
+ () => (module['default']) :
57
+ () => (module);
58
+ __webpack_require__.d(getter, { a: getter });
59
+ return getter;
60
+ };
61
+
62
+ })();
63
+ // webpack/runtime/define_property_getters
64
+ (() => {
65
+ __webpack_require__.d = (exports, getters, values) => {
66
+ var define = (defs, kind) => {
67
+ for(var key in defs) {
68
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
69
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
70
+ }
71
+ }
72
+ };
73
+ define(getters, "get");
74
+ define(values, "value");
75
+ };
76
+ })();
77
+ // webpack/runtime/has_own_property
78
+ (() => {
79
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
80
+ })();
81
+ // webpack/runtime/make_namespace_object
82
+ (() => {
83
+ // define __esModule on exports
84
+ __webpack_require__.r = (exports) => {
85
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
86
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
87
+ }
88
+ Object.defineProperty(exports, '__esModule', { value: true });
89
+ };
90
+ })();
91
+ var __webpack_exports__ = {};
92
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
93
+ (() => {
94
+ __webpack_require__.r(__webpack_exports__);
95
+ /* import */ var _StatsPlugin__rspack_import_0 = __webpack_require__("./StatsPlugin");
96
+ /* import */ var _StatsPlugin__rspack_import_0_default = /*#__PURE__*/__webpack_require__.n(_StatsPlugin__rspack_import_0);
97
+ /* import */ var _ManifestManager__rspack_import_1 = __webpack_require__("./ManifestManager");
98
+ /* import */ var _ManifestManager__rspack_import_1_default = /*#__PURE__*/__webpack_require__.n(_ManifestManager__rspack_import_1);
99
+ /* import */ var _StatsManager__rspack_import_2 = __webpack_require__("./StatsManager");
100
+ /* import */ var _StatsManager__rspack_import_2_default = /*#__PURE__*/__webpack_require__.n(_StatsManager__rspack_import_2);
101
+ /* import */ var _types__rspack_import_3 = __webpack_require__("./types");
102
+ /* import */ var _types__rspack_import_3_default = /*#__PURE__*/__webpack_require__.n(_types__rspack_import_3);
103
+
104
+ /* reexport */ var __rspack_reexport = {};
105
+ /* reexport */ for( const __rspack_import_key in _types__rspack_import_3) if(["StatsPlugin","ManifestManager","default","StatsManager"].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] =() => _types__rspack_import_3[__rspack_import_key]
106
+ /* reexport */ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
107
+
108
+
109
+
110
+
111
+
112
+ __webpack_require__.d(__webpack_exports__, {
113
+ ManifestManager: () => (/* reexport safe */ _ManifestManager__rspack_import_1.ManifestManager),
114
+ StatsManager: () => (/* reexport safe */ _StatsManager__rspack_import_2.StatsManager),
115
+ StatsPlugin: () => (/* reexport safe */ _StatsPlugin__rspack_import_0.StatsPlugin)
116
+ });
117
+
118
+ })();
119
+
120
+ exports.ManifestManager = __webpack_exports__.ManifestManager;
121
+ exports.StatsManager = __webpack_exports__.StatsManager;
122
+ exports.StatsPlugin = __webpack_exports__.StatsPlugin;
123
+ for(var __rspack_i in __webpack_exports__) {
124
+ if(["ManifestManager","StatsManager","StatsPlugin"].indexOf(__rspack_i) === -1) {
125
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
126
+ }
127
+ }
128
+ Object.defineProperty(exports, '__esModule', { value: true });
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./types.mjs";
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export { StatsPlugin } from "./StatsPlugin.mjs";
11
+ export { ManifestManager } from "./ManifestManager.mjs";
12
+ export { StatsManager } from "./StatsManager.mjs";
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
package/dist/logger.js ADDED
@@ -0,0 +1,69 @@
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
+ "default": () => (/* binding */ src_logger)
47
+ });
48
+
49
+ ;// CONCATENATED MODULE: external "node:util"
50
+ const external_node_util_namespaceObject = require("node:util");
51
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
52
+ const sdk_namespaceObject = require("@module-federation/sdk");
53
+ ;// CONCATENATED MODULE: external "./constants.js"
54
+ const external_constants_js_namespaceObject = require("./constants.js");
55
+ ;// CONCATENATED MODULE: ./src/logger.ts
56
+
57
+
58
+
59
+ const createBundlerLogger = typeof sdk_namespaceObject.createInfrastructureLogger === 'function' ? sdk_namespaceObject.createInfrastructureLogger : sdk_namespaceObject.createLogger;
60
+ const logger = createBundlerLogger((0,external_node_util_namespaceObject.styleText)('cyan', `[ ${external_constants_js_namespaceObject.PLUGIN_IDENTIFIER} ]`));
61
+ /* export default */ const src_logger = (logger);
62
+
63
+ exports["default"] = __webpack_exports__["default"];
64
+ for(var __rspack_i in __webpack_exports__) {
65
+ if(["default"].indexOf(__rspack_i) === -1) {
66
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
67
+ }
68
+ }
69
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,15 @@
1
+ import { styleText } from "node:util";
2
+ import { createInfrastructureLogger, createLogger } from "@module-federation/sdk";
3
+ import { PLUGIN_IDENTIFIER } from "./constants.mjs";
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ const createBundlerLogger = typeof createInfrastructureLogger === 'function' ? createInfrastructureLogger : createLogger;
12
+ const logger = createBundlerLogger(styleText('cyan', `[ ${PLUGIN_IDENTIFIER} ]`));
13
+ /* export default */ const src_logger = (logger);
14
+
15
+ export default src_logger;
@@ -0,0 +1,13 @@
1
+ import { Manifest, Stats } from '@module-federation/sdk';
2
+ export type StatsInfo = {
3
+ stats: Stats;
4
+ filename: string;
5
+ };
6
+ export type ManifestInfo = {
7
+ manifest: Manifest;
8
+ filename: string;
9
+ };
10
+ export type ResourceInfo = {
11
+ stats: StatsInfo;
12
+ manifest: ManifestInfo;
13
+ };
package/dist/types.js ADDED
@@ -0,0 +1,29 @@
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/make_namespace_object
13
+ (() => {
14
+ // define __esModule on exports
15
+ __webpack_require__.r = (exports) => {
16
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ }
19
+ Object.defineProperty(exports, '__esModule', { value: true });
20
+ };
21
+ })();
22
+ var __webpack_exports__ = {};
23
+ __webpack_require__.r(__webpack_exports__);
24
+
25
+
26
+ for(var __rspack_i in __webpack_exports__) {
27
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
28
+ }
29
+ Object.defineProperty(exports, '__esModule', { value: true });
package/dist/types.mjs ADDED
@@ -0,0 +1,3 @@
1
+
2
+
3
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Chunk, Compilation } from 'webpack';
2
+ import type { StatsCompilation, StatsModule } from 'webpack/lib/stats/DefaultStatsFactoryPlugin';
3
+ import { StatsAssets, moduleFederationPlugin, MetaDataTypes } from '@module-federation/sdk';
4
+ export declare function getAssetsByChunkIDs(compilation: Compilation, chunkIDMap: Record<string, Set<string | number>>): Record<string, {
5
+ js: string[];
6
+ css: string[];
7
+ }>;
8
+ export declare function findChunk(id: string | number, chunks: Set<Chunk>): Chunk | void;
9
+ export declare function getSharedModules(stats: StatsCompilation, sharedModules: StatsModule[]): [string, StatsModule][];
10
+ export declare function getAssetsByChunk(chunk: Chunk, entryPointNames: Array<string>): StatsAssets;
11
+ export declare function assert(condition: any, msg: string): asserts condition;
12
+ export declare function error(msg: string | Error | unknown): never;
13
+ export declare function isDev(): boolean;
14
+ export declare function getFileNameWithOutExt(str: string): string;
15
+ export declare function getTypesMetaInfo(pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, context: string): MetaDataTypes;