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