@depup/module-federation__manifest 2.2.2-depup.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.
package/dist/utils.js ADDED
@@ -0,0 +1,296 @@
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
+ findChunk: () => (/* binding */ findChunk),
57
+ getSharedModules: () => (/* binding */ getSharedModules),
58
+ getTypesMetaInfo: () => (/* binding */ getTypesMetaInfo),
59
+ isDev: () => (/* binding */ isDev),
60
+ getFileNameWithOutExt: () => (/* binding */ getFileNameWithOutExt),
61
+ getAssetsByChunk: () => (/* binding */ getAssetsByChunk),
62
+ error: () => (/* binding */ error),
63
+ getAssetsByChunkIDs: () => (/* binding */ getAssetsByChunkIDs),
64
+ assert: () => (/* binding */ assert)
65
+ });
66
+
67
+ ;// CONCATENATED MODULE: external "path"
68
+ const external_path_namespaceObject = require("path");
69
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
70
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
71
+ const sdk_namespaceObject = require("@module-federation/sdk");
72
+ ;// CONCATENATED MODULE: external "@module-federation/dts-plugin/core"
73
+ const core_namespaceObject = require("@module-federation/dts-plugin/core");
74
+ ;// CONCATENATED MODULE: external "./constants.js"
75
+ const external_constants_js_namespaceObject = require("./constants.js");
76
+ ;// CONCATENATED MODULE: external "./logger.js"
77
+ const external_logger_js_namespaceObject = require("./logger.js");
78
+ var external_logger_js_default = /*#__PURE__*/__webpack_require__.n(external_logger_js_namespaceObject);
79
+ ;// CONCATENATED MODULE: ./src/utils.ts
80
+
81
+
82
+
83
+
84
+
85
+ function isHotFile(file) {
86
+ return file.includes(external_constants_js_namespaceObject.HOT_UPDATE_SUFFIX);
87
+ }
88
+ const collectAssets = (assets, jsTargetSet, cssTargetSet)=>{
89
+ assets.forEach((file)=>{
90
+ if (file.endsWith('.css')) {
91
+ cssTargetSet.add(file);
92
+ } else {
93
+ if (isDev()) {
94
+ if (!isHotFile(file)) {
95
+ jsTargetSet.add(file);
96
+ }
97
+ } else {
98
+ jsTargetSet.add(file);
99
+ }
100
+ }
101
+ });
102
+ };
103
+ function getSharedModuleName(name) {
104
+ const [_type, _shared, _module, _shareScope, sharedInfo] = name.split(' ');
105
+ return sharedInfo.split('@').slice(0, -1).join('@');
106
+ }
107
+ function getAssetsByChunkIDs(compilation, chunkIDMap) {
108
+ const arrayChunks = Array.from(compilation.chunks);
109
+ const assetMap = {};
110
+ Object.keys(chunkIDMap).forEach((key)=>{
111
+ const chunkIDs = Array.from(chunkIDMap[key]);
112
+ if (!assetMap[key]) {
113
+ assetMap[key] = {
114
+ css: new Set(),
115
+ js: new Set()
116
+ };
117
+ }
118
+ chunkIDs.forEach((chunkID)=>{
119
+ const chunk = arrayChunks.find((item)=>item.id === chunkID);
120
+ if (chunk) {
121
+ collectAssets([
122
+ ...chunk.files
123
+ ], assetMap[key].js, assetMap[key].css);
124
+ }
125
+ });
126
+ });
127
+ const assets = {};
128
+ Object.keys(assetMap).map((key)=>{
129
+ assets[key] = {
130
+ js: Array.from(assetMap[key].js),
131
+ css: Array.from(assetMap[key].css)
132
+ };
133
+ });
134
+ return assets;
135
+ }
136
+ function findChunk(id, chunks) {
137
+ for (const chunk of chunks){
138
+ if (id === chunk.id) {
139
+ return chunk;
140
+ }
141
+ }
142
+ }
143
+ function getSharedModules(stats, sharedModules) {
144
+ var _stats_modules;
145
+ // 获取入口文件就是实际内容的 module
146
+ const entryContentModuleNames = [];
147
+ let effectiveSharedModules = ((_stats_modules = stats.modules) === null || _stats_modules === void 0 ? void 0 : _stats_modules.reduce((sum, module)=>{
148
+ for (const sharedModule of sharedModules){
149
+ if (sharedModule.name === module.issuerName) {
150
+ entryContentModuleNames.push(sharedModule.name);
151
+ sum.push([
152
+ getSharedModuleName(module.issuerName),
153
+ module
154
+ ]);
155
+ return sum;
156
+ }
157
+ }
158
+ return sum;
159
+ }, [])) || [];
160
+ // 获取入口文件仅作为 Re Export 的 module
161
+ const entryReExportModules = sharedModules.filter((sharedModule)=>!entryContentModuleNames.includes(sharedModule.name));
162
+ if (entryReExportModules.length) {
163
+ effectiveSharedModules = effectiveSharedModules.concat(stats.modules.reduce((sum, module)=>{
164
+ let flag = false;
165
+ for (const entryReExportModule of entryReExportModules){
166
+ if (flag) {
167
+ break;
168
+ }
169
+ if (module.reasons) {
170
+ for (const issueModule of module.reasons){
171
+ if (issueModule.moduleName === entryReExportModule.name) {
172
+ sum.push([
173
+ getSharedModuleName(entryReExportModule.name),
174
+ module
175
+ ]);
176
+ flag = true;
177
+ break;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ return sum;
183
+ }, []));
184
+ }
185
+ return effectiveSharedModules;
186
+ }
187
+ function getAssetsByChunk(chunk, entryPointNames) {
188
+ const assesSet = {
189
+ js: {
190
+ sync: new Set(),
191
+ async: new Set()
192
+ },
193
+ css: {
194
+ sync: new Set(),
195
+ async: new Set()
196
+ }
197
+ };
198
+ const collectChunkFiles = (targetChunk, type)=>{
199
+ [
200
+ ...targetChunk.groupsIterable
201
+ ].forEach((chunkGroup)=>{
202
+ if (chunkGroup.name && !entryPointNames.includes(chunkGroup.name)) {
203
+ collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
204
+ }
205
+ });
206
+ };
207
+ collectChunkFiles(chunk, 'sync');
208
+ [
209
+ ...chunk.getAllAsyncChunks()
210
+ ].forEach((asyncChunk)=>{
211
+ collectAssets([
212
+ ...asyncChunk.files
213
+ ], assesSet.js['async'], assesSet.css['async']);
214
+ collectChunkFiles(asyncChunk, 'async');
215
+ });
216
+ const assets = {
217
+ js: {
218
+ sync: Array.from(assesSet.js.sync),
219
+ async: Array.from(assesSet.js.async)
220
+ },
221
+ css: {
222
+ sync: Array.from(assesSet.css.sync),
223
+ async: Array.from(assesSet.css.async)
224
+ }
225
+ };
226
+ return assets;
227
+ }
228
+ function assert(condition, msg) {
229
+ if (!condition) {
230
+ error(msg);
231
+ }
232
+ }
233
+ function error(msg) {
234
+ throw new Error(`[ ${external_constants_js_namespaceObject.PLUGIN_IDENTIFIER} ]: ${msg}`);
235
+ }
236
+ function isDev() {
237
+ return process.env['NODE_ENV'] === 'development';
238
+ }
239
+ function getFileNameWithOutExt(str) {
240
+ return str.replace(external_path_default().extname(str), '');
241
+ }
242
+ function getTypesMetaInfo(pluginOptions, context) {
243
+ const defaultRemoteOptions = {
244
+ generateAPITypes: true,
245
+ compileInChildProcess: true
246
+ };
247
+ const defaultTypesMetaInfo = {
248
+ path: '',
249
+ name: '',
250
+ zip: '',
251
+ api: ''
252
+ };
253
+ try {
254
+ const normalizedDtsOptions = (0,sdk_namespaceObject.normalizeOptions)((0,core_namespaceObject.isTSProject)(pluginOptions.dts, context), {
255
+ generateTypes: defaultRemoteOptions,
256
+ consumeTypes: {}
257
+ }, 'mfOptions.dts')(pluginOptions.dts);
258
+ if (normalizedDtsOptions === false) {
259
+ return defaultTypesMetaInfo;
260
+ }
261
+ const normalizedRemote = (0,sdk_namespaceObject.normalizeOptions)(true, defaultRemoteOptions, 'mfOptions.dts.generateTypes')(normalizedDtsOptions.generateTypes);
262
+ if (normalizedRemote === false) {
263
+ return defaultTypesMetaInfo;
264
+ }
265
+ const { apiFileName, zipName } = (0,core_namespaceObject.retrieveTypesAssetsInfo)({
266
+ ...normalizedRemote,
267
+ context,
268
+ moduleFederationConfig: pluginOptions
269
+ });
270
+ return {
271
+ path: '',
272
+ name: '',
273
+ zip: zipName,
274
+ api: apiFileName
275
+ };
276
+ } catch (err) {
277
+ external_logger_js_default().warn(`getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ${err}`);
278
+ return defaultTypesMetaInfo;
279
+ }
280
+ }
281
+
282
+ exports.assert = __webpack_exports__.assert;
283
+ exports.error = __webpack_exports__.error;
284
+ exports.findChunk = __webpack_exports__.findChunk;
285
+ exports.getAssetsByChunk = __webpack_exports__.getAssetsByChunk;
286
+ exports.getAssetsByChunkIDs = __webpack_exports__.getAssetsByChunkIDs;
287
+ exports.getFileNameWithOutExt = __webpack_exports__.getFileNameWithOutExt;
288
+ exports.getSharedModules = __webpack_exports__.getSharedModules;
289
+ exports.getTypesMetaInfo = __webpack_exports__.getTypesMetaInfo;
290
+ exports.isDev = __webpack_exports__.isDev;
291
+ for(var __webpack_i__ in __webpack_exports__) {
292
+ if(["assert","error","findChunk","getAssetsByChunk","getAssetsByChunkIDs","getFileNameWithOutExt","getSharedModules","getTypesMetaInfo","isDev"].indexOf(__webpack_i__) === -1) {
293
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
294
+ }
295
+ }
296
+ Object.defineProperty(exports, '__esModule', { value: true });
package/dist/utils.mjs ADDED
@@ -0,0 +1,220 @@
1
+ import path from "path";
2
+ import { normalizeOptions } from "@module-federation/sdk";
3
+ import { isTSProject, retrieveTypesAssetsInfo } from "@module-federation/dts-plugin/core";
4
+ import { HOT_UPDATE_SUFFIX, PLUGIN_IDENTIFIER } from "./constants.mjs";
5
+ import logger from "./logger.mjs";
6
+
7
+ ;// CONCATENATED MODULE: external "path"
8
+
9
+ ;// CONCATENATED MODULE: external "@module-federation/sdk"
10
+
11
+ ;// CONCATENATED MODULE: external "@module-federation/dts-plugin/core"
12
+
13
+ ;// CONCATENATED MODULE: external "./constants.mjs"
14
+
15
+ ;// CONCATENATED MODULE: external "./logger.mjs"
16
+
17
+ ;// CONCATENATED MODULE: ./src/utils.ts
18
+
19
+
20
+
21
+
22
+
23
+ function isHotFile(file) {
24
+ return file.includes(HOT_UPDATE_SUFFIX);
25
+ }
26
+ const collectAssets = (assets, jsTargetSet, cssTargetSet)=>{
27
+ assets.forEach((file)=>{
28
+ if (file.endsWith('.css')) {
29
+ cssTargetSet.add(file);
30
+ } else {
31
+ if (isDev()) {
32
+ if (!isHotFile(file)) {
33
+ jsTargetSet.add(file);
34
+ }
35
+ } else {
36
+ jsTargetSet.add(file);
37
+ }
38
+ }
39
+ });
40
+ };
41
+ function getSharedModuleName(name) {
42
+ const [_type, _shared, _module, _shareScope, sharedInfo] = name.split(' ');
43
+ return sharedInfo.split('@').slice(0, -1).join('@');
44
+ }
45
+ function getAssetsByChunkIDs(compilation, chunkIDMap) {
46
+ const arrayChunks = Array.from(compilation.chunks);
47
+ const assetMap = {};
48
+ Object.keys(chunkIDMap).forEach((key)=>{
49
+ const chunkIDs = Array.from(chunkIDMap[key]);
50
+ if (!assetMap[key]) {
51
+ assetMap[key] = {
52
+ css: new Set(),
53
+ js: new Set()
54
+ };
55
+ }
56
+ chunkIDs.forEach((chunkID)=>{
57
+ const chunk = arrayChunks.find((item)=>item.id === chunkID);
58
+ if (chunk) {
59
+ collectAssets([
60
+ ...chunk.files
61
+ ], assetMap[key].js, assetMap[key].css);
62
+ }
63
+ });
64
+ });
65
+ const assets = {};
66
+ Object.keys(assetMap).map((key)=>{
67
+ assets[key] = {
68
+ js: Array.from(assetMap[key].js),
69
+ css: Array.from(assetMap[key].css)
70
+ };
71
+ });
72
+ return assets;
73
+ }
74
+ function findChunk(id, chunks) {
75
+ for (const chunk of chunks){
76
+ if (id === chunk.id) {
77
+ return chunk;
78
+ }
79
+ }
80
+ }
81
+ function getSharedModules(stats, sharedModules) {
82
+ var _stats_modules;
83
+ // 获取入口文件就是实际内容的 module
84
+ const entryContentModuleNames = [];
85
+ let effectiveSharedModules = ((_stats_modules = stats.modules) === null || _stats_modules === void 0 ? void 0 : _stats_modules.reduce((sum, module)=>{
86
+ for (const sharedModule of sharedModules){
87
+ if (sharedModule.name === module.issuerName) {
88
+ entryContentModuleNames.push(sharedModule.name);
89
+ sum.push([
90
+ getSharedModuleName(module.issuerName),
91
+ module
92
+ ]);
93
+ return sum;
94
+ }
95
+ }
96
+ return sum;
97
+ }, [])) || [];
98
+ // 获取入口文件仅作为 Re Export 的 module
99
+ const entryReExportModules = sharedModules.filter((sharedModule)=>!entryContentModuleNames.includes(sharedModule.name));
100
+ if (entryReExportModules.length) {
101
+ effectiveSharedModules = effectiveSharedModules.concat(stats.modules.reduce((sum, module)=>{
102
+ let flag = false;
103
+ for (const entryReExportModule of entryReExportModules){
104
+ if (flag) {
105
+ break;
106
+ }
107
+ if (module.reasons) {
108
+ for (const issueModule of module.reasons){
109
+ if (issueModule.moduleName === entryReExportModule.name) {
110
+ sum.push([
111
+ getSharedModuleName(entryReExportModule.name),
112
+ module
113
+ ]);
114
+ flag = true;
115
+ break;
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return sum;
121
+ }, []));
122
+ }
123
+ return effectiveSharedModules;
124
+ }
125
+ function getAssetsByChunk(chunk, entryPointNames) {
126
+ const assesSet = {
127
+ js: {
128
+ sync: new Set(),
129
+ async: new Set()
130
+ },
131
+ css: {
132
+ sync: new Set(),
133
+ async: new Set()
134
+ }
135
+ };
136
+ const collectChunkFiles = (targetChunk, type)=>{
137
+ [
138
+ ...targetChunk.groupsIterable
139
+ ].forEach((chunkGroup)=>{
140
+ if (chunkGroup.name && !entryPointNames.includes(chunkGroup.name)) {
141
+ collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
142
+ }
143
+ });
144
+ };
145
+ collectChunkFiles(chunk, 'sync');
146
+ [
147
+ ...chunk.getAllAsyncChunks()
148
+ ].forEach((asyncChunk)=>{
149
+ collectAssets([
150
+ ...asyncChunk.files
151
+ ], assesSet.js['async'], assesSet.css['async']);
152
+ collectChunkFiles(asyncChunk, 'async');
153
+ });
154
+ const assets = {
155
+ js: {
156
+ sync: Array.from(assesSet.js.sync),
157
+ async: Array.from(assesSet.js.async)
158
+ },
159
+ css: {
160
+ sync: Array.from(assesSet.css.sync),
161
+ async: Array.from(assesSet.css.async)
162
+ }
163
+ };
164
+ return assets;
165
+ }
166
+ function assert(condition, msg) {
167
+ if (!condition) {
168
+ error(msg);
169
+ }
170
+ }
171
+ function error(msg) {
172
+ throw new Error(`[ ${PLUGIN_IDENTIFIER} ]: ${msg}`);
173
+ }
174
+ function isDev() {
175
+ return process.env['NODE_ENV'] === 'development';
176
+ }
177
+ function getFileNameWithOutExt(str) {
178
+ return str.replace(path.extname(str), '');
179
+ }
180
+ function getTypesMetaInfo(pluginOptions, context) {
181
+ const defaultRemoteOptions = {
182
+ generateAPITypes: true,
183
+ compileInChildProcess: true
184
+ };
185
+ const defaultTypesMetaInfo = {
186
+ path: '',
187
+ name: '',
188
+ zip: '',
189
+ api: ''
190
+ };
191
+ try {
192
+ const normalizedDtsOptions = normalizeOptions(isTSProject(pluginOptions.dts, context), {
193
+ generateTypes: defaultRemoteOptions,
194
+ consumeTypes: {}
195
+ }, 'mfOptions.dts')(pluginOptions.dts);
196
+ if (normalizedDtsOptions === false) {
197
+ return defaultTypesMetaInfo;
198
+ }
199
+ const normalizedRemote = normalizeOptions(true, defaultRemoteOptions, 'mfOptions.dts.generateTypes')(normalizedDtsOptions.generateTypes);
200
+ if (normalizedRemote === false) {
201
+ return defaultTypesMetaInfo;
202
+ }
203
+ const { apiFileName, zipName } = retrieveTypesAssetsInfo({
204
+ ...normalizedRemote,
205
+ context,
206
+ moduleFederationConfig: pluginOptions
207
+ });
208
+ return {
209
+ path: '',
210
+ name: '',
211
+ zip: zipName,
212
+ api: apiFileName
213
+ };
214
+ } catch (err) {
215
+ logger.warn(`getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ${err}`);
216
+ return defaultTypesMetaInfo;
217
+ }
218
+ }
219
+
220
+ export { assert, error, findChunk, getAssetsByChunk, getAssetsByChunkIDs, getFileNameWithOutExt, getSharedModules, getTypesMetaInfo, isDev };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@depup/module-federation__manifest",
3
+ "version": "2.2.2-depup.0",
4
+ "license": "MIT",
5
+ "description": "[DepUp] Provide manifest/stats for webpack/rspack MF project .",
6
+ "keywords": [
7
+ "depup",
8
+ "dependency-bumped",
9
+ "updated-deps",
10
+ "@module-federation/manifest",
11
+ "Module Federation",
12
+ "Webpack",
13
+ "Rspack",
14
+ "Manifest"
15
+ ],
16
+ "files": [
17
+ "dist/",
18
+ "README.md",
19
+ "changes.json"
20
+ ],
21
+ "author": "hanric <hanric.zhang@gmail.com>",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/module-federation/core.git",
25
+ "directory": "packages/manifest"
26
+ },
27
+ "sideEffects": false,
28
+ "main": "./dist/index.js",
29
+ "module": "./dist/index.mjs",
30
+ "types": "./dist/index.d.ts",
31
+ "dependencies": {
32
+ "find-pkg": "2.0.0",
33
+ "chalk": "^5.6.2",
34
+ "@module-federation/sdk": "2.2.2",
35
+ "@module-federation/dts-plugin": "2.2.2",
36
+ "@module-federation/managers": "2.2.2"
37
+ },
38
+ "exports": {
39
+ ".": {
40
+ "import": {
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.mjs"
43
+ },
44
+ "require": {
45
+ "types": "./dist/index.d.ts",
46
+ "default": "./dist/index.js"
47
+ }
48
+ }
49
+ },
50
+ "typesVersions": {
51
+ "*": {
52
+ ".": [
53
+ "./dist/index.d.ts"
54
+ ]
55
+ }
56
+ },
57
+ "devDependencies": {
58
+ "webpack": "^5.0.0"
59
+ },
60
+ "scripts": {
61
+ "build": "rslib build",
62
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
63
+ "test": "pnpm exec jest --config jest.config.js --passWithNoTests",
64
+ "test:ci": "pnpm exec jest --config jest.config.js --passWithNoTests --ci --coverage",
65
+ "pre-release": "pnpm run test && pnpm run build"
66
+ },
67
+ "depup": {
68
+ "changes": {
69
+ "chalk": {
70
+ "from": "3.0.0",
71
+ "to": "^5.6.2"
72
+ }
73
+ },
74
+ "depsUpdated": 1,
75
+ "originalPackage": "@module-federation/manifest",
76
+ "originalVersion": "2.2.2",
77
+ "processedAt": "2026-03-17T16:32:11.243Z",
78
+ "smokeTest": "passed"
79
+ }
80
+ }