zephyr-repack-plugin 0.0.0-canary-20241118144314
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 +39 -0
- package/README.md +3 -0
- package/dist/README.md +3 -0
- package/dist/delegate-module/delegate-module-template.d.ts +1 -0
- package/dist/delegate-module/delegate-module-template.js +74 -0
- package/dist/delegate-module/delegate-module-template.js.map +1 -0
- package/dist/delegate-module/replace-remote-with-delegate.d.ts +2 -0
- package/dist/delegate-module/replace-remote-with-delegate.js +29 -0
- package/dist/delegate-module/replace-remote-with-delegate.js.map +1 -0
- package/dist/delegate-module/zephyr-delegate.d.ts +7 -0
- package/dist/delegate-module/zephyr-delegate.js +103 -0
- package/dist/delegate-module/zephyr-delegate.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/build-stats/get-build-stats.d.ts +6 -0
- package/dist/lib/build-stats/get-build-stats.js +55 -0
- package/dist/lib/build-stats/get-build-stats.js.map +1 -0
- package/dist/lib/dependency-resolution/replace-remote-with-delegates.d.ts +3 -0
- package/dist/lib/dependency-resolution/replace-remote-with-delegates.js +21 -0
- package/dist/lib/dependency-resolution/replace-remote-with-delegates.js.map +1 -0
- package/dist/lib/federation-graph/compute-dependencies.d.ts +10 -0
- package/dist/lib/federation-graph/compute-dependencies.js +69 -0
- package/dist/lib/federation-graph/compute-dependencies.js.map +1 -0
- package/dist/lib/federation-graph/compute-shared-module.d.ts +1 -0
- package/dist/lib/federation-graph/compute-shared-module.js +3 -0
- package/dist/lib/federation-graph/compute-shared-module.js.map +1 -0
- package/dist/lib/federation-graph/compute-version.d.ts +4 -0
- package/dist/lib/federation-graph/compute-version.js +22 -0
- package/dist/lib/federation-graph/compute-version.js.map +1 -0
- package/dist/lib/federation-graph/federation-plugin.d.ts +49 -0
- package/dist/lib/federation-graph/federation-plugin.js +223 -0
- package/dist/lib/federation-graph/federation-plugin.js.map +1 -0
- package/dist/lib/federation-graph/runtime-requirement.d.ts +4 -0
- package/dist/lib/federation-graph/runtime-requirement.js +28 -0
- package/dist/lib/federation-graph/runtime-requirement.js.map +1 -0
- package/dist/lib/federation-graph/utils/convert-dependencies.d.ts +12 -0
- package/dist/lib/federation-graph/utils/convert-dependencies.js +31 -0
- package/dist/lib/federation-graph/utils/convert-dependencies.js.map +1 -0
- package/dist/lib/federation-graph/utils/convert-to-graph.d.ts +3 -0
- package/dist/lib/federation-graph/utils/convert-to-graph.js +53 -0
- package/dist/lib/federation-graph/utils/convert-to-graph.js.map +1 -0
- package/dist/lib/federation-graph/utils/converted-dependencies.d.ts +12 -0
- package/dist/lib/federation-graph/utils/converted-dependencies.js +31 -0
- package/dist/lib/federation-graph/utils/converted-dependencies.js.map +1 -0
- package/dist/lib/federation-graph/utils/get-licenses.d.ts +2 -0
- package/dist/lib/federation-graph/utils/get-licenses.js +23 -0
- package/dist/lib/federation-graph/utils/get-licenses.js.map +1 -0
- package/dist/lib/federation-graph/utils/module-part-one.d.ts +31 -0
- package/dist/lib/federation-graph/utils/module-part-one.js +133 -0
- package/dist/lib/federation-graph/utils/module-part-one.js.map +1 -0
- package/dist/lib/federation-graph/utils/module-part-two.d.ts +50 -0
- package/dist/lib/federation-graph/utils/module-part-two.js +134 -0
- package/dist/lib/federation-graph/utils/module-part-two.js.map +1 -0
- package/dist/lib/federation-graph/utils/process-function-remotes.d.ts +22 -0
- package/dist/lib/federation-graph/utils/process-function-remotes.js +35 -0
- package/dist/lib/federation-graph/utils/process-function-remotes.js.map +1 -0
- package/dist/lib/federation-graph/validate-params.d.ts +0 -0
- package/dist/lib/federation-graph/validate-params.js +2 -0
- package/dist/lib/federation-graph/validate-params.js.map +1 -0
- package/dist/lib/set-up-build-id.d.ts +3 -0
- package/dist/lib/set-up-build-id.js +43 -0
- package/dist/lib/set-up-build-id.js.map +1 -0
- package/dist/lib/set-up-build-stats-logging.d.ts +5 -0
- package/dist/lib/set-up-build-stats-logging.js +26 -0
- package/dist/lib/set-up-build-stats-logging.js.map +1 -0
- package/dist/lib/set-up-deploy.d.ts +3 -0
- package/dist/lib/set-up-deploy.js +35 -0
- package/dist/lib/set-up-deploy.js.map +1 -0
- package/dist/lib/utils/federation-plugin-get-package-json.d.ts +1 -0
- package/dist/lib/utils/federation-plugin-get-package-json.js +23 -0
- package/dist/lib/utils/federation-plugin-get-package-json.js.map +1 -0
- package/dist/lib/utils/get-mf-config.d.ts +6 -0
- package/dist/lib/utils/get-mf-config.js +26 -0
- package/dist/lib/utils/get-mf-config.js.map +1 -0
- package/dist/lib/utils/get-platform.d.ts +5 -0
- package/dist/lib/utils/get-platform.js +9 -0
- package/dist/lib/utils/get-platform.js.map +1 -0
- package/dist/lib/utils/plugin-search.d.ts +5 -0
- package/dist/lib/utils/plugin-search.js +17 -0
- package/dist/lib/utils/plugin-search.js.map +1 -0
- package/dist/lib/with-zephyr.d.ts +3 -0
- package/dist/lib/with-zephyr.js +50 -0
- package/dist/lib/with-zephyr.js.map +1 -0
- package/dist/lib/ze-agent/index.d.ts +9 -0
- package/dist/lib/ze-agent/index.js +53 -0
- package/dist/lib/ze-agent/index.js.map +1 -0
- package/dist/lib/ze-agent/lifecycle-events.d.ts +2 -0
- package/dist/lib/ze-agent/lifecycle-events.js +20 -0
- package/dist/lib/ze-agent/lifecycle-events.js.map +1 -0
- package/dist/lib/ze-repack-plugin.d.ts +7 -0
- package/dist/lib/ze-repack-plugin.js +30 -0
- package/dist/lib/ze-repack-plugin.js.map +1 -0
- package/dist/package.json +26 -0
- package/dist/type/convert-graph-params.d.ts +48 -0
- package/dist/type/convert-graph-params.js +3 -0
- package/dist/type/convert-graph-params.js.map +1 -0
- package/dist/type/federation-plugin-options.d.ts +62 -0
- package/dist/type/federation-plugin-options.js +3 -0
- package/dist/type/federation-plugin-options.js.map +1 -0
- package/dist/type/zephyr-internal-types.d.ts +23 -0
- package/dist/type/zephyr-internal-types.js +3 -0
- package/dist/type/zephyr-internal-types.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FederationDashboardPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
7
|
+
const zephyr_edge_contract_2 = require("zephyr-edge-contract");
|
|
8
|
+
const compute_version_1 = require("./compute-version");
|
|
9
|
+
const runtime_requirement_1 = require("./runtime-requirement");
|
|
10
|
+
const plugin_search_1 = require("../utils/plugin-search");
|
|
11
|
+
const federation_plugin_get_package_json_1 = require("../utils/federation-plugin-get-package-json");
|
|
12
|
+
const compute_dependencies_1 = tslib_1.__importDefault(require("./compute-dependencies"));
|
|
13
|
+
const convert_to_graph_1 = require("./utils/convert-to-graph");
|
|
14
|
+
const remote_entry_last_part = 'mf-manifest.json';
|
|
15
|
+
class FederationDashboardPlugin {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.allArgumentsUsed = [];
|
|
18
|
+
this.FederationPluginOptions = {};
|
|
19
|
+
this._options = Object.assign({
|
|
20
|
+
debug: false, // TODO?
|
|
21
|
+
useAST: false, // TODO?
|
|
22
|
+
}, options);
|
|
23
|
+
}
|
|
24
|
+
/** @param {Compiler} compiler */
|
|
25
|
+
apply(compiler) {
|
|
26
|
+
compiler.options.output.uniqueName = `v${Date.now()}`; // TODO, use user_buildID version
|
|
27
|
+
new runtime_requirement_1.AddRuntimeRequirementToPromiseExternal().apply(compiler);
|
|
28
|
+
const FederationPlugin = compiler.options.plugins.find(plugin_search_1.is_module_federation_plugin);
|
|
29
|
+
// If FederationPlugin doesn't exists this is a standalone app, we don't need to do anything
|
|
30
|
+
this._options.standalone = typeof FederationPlugin === 'undefined';
|
|
31
|
+
if (FederationPlugin) {
|
|
32
|
+
this.FederationPluginOptions = Object.assign({}, FederationPlugin._options, this._options.standalone || {});
|
|
33
|
+
}
|
|
34
|
+
else if (this._options.standalone) {
|
|
35
|
+
this.FederationPluginOptions = {};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error('Statistic plugin is missing Module Federation of standalone option');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
processRspackGraph({ stats, stats_json, pluginOptions }) {
|
|
42
|
+
this.FederationPluginOptions = Object.assign({}, this.FederationPluginOptions, pluginOptions.mfConfig);
|
|
43
|
+
const RemoteEntryChunk = this.getRemoteEntryChunk(stats_json, this.FederationPluginOptions);
|
|
44
|
+
const validChunkArray = this.buildValidChunkArray(stats, this.FederationPluginOptions);
|
|
45
|
+
const chunkDependencies = this.getChunkDependencies(validChunkArray);
|
|
46
|
+
const vendorFederation = this.buildVendorFederationMap(stats);
|
|
47
|
+
// TODO: this type casting might not be every compilation result from rspack, but it's fine for now
|
|
48
|
+
const getPlatformFromStats = stats.compilation.name;
|
|
49
|
+
const remotes = this.FederationPluginOptions?.remotes ? Object.keys(this.FederationPluginOptions.remotes) : [];
|
|
50
|
+
const rawData = {
|
|
51
|
+
name: this.FederationPluginOptions?.name,
|
|
52
|
+
remotes: remotes,
|
|
53
|
+
metadata: this.attach_remote_bundle_name_to_metadata() || {},
|
|
54
|
+
topLevelPackage: vendorFederation || {},
|
|
55
|
+
publicPath: stats_json.publicPath,
|
|
56
|
+
federationRemoteEntry: RemoteEntryChunk,
|
|
57
|
+
buildHash: stats_json.hash,
|
|
58
|
+
environment: this._options.environment || 'development', // 'development' if not specified
|
|
59
|
+
version: (0, compute_version_1.computeVersionStrategy)(stats_json, this._options.versionStrategy),
|
|
60
|
+
posted: this._options.posted || new Date(), // Date.now() if not specified
|
|
61
|
+
group: this._options.group, // 'default' if not specified, prior history be "group" is our project name, in the future we might want to reuse this field in case project name is not in the same repository.
|
|
62
|
+
sha: compute_version_1.gitSha,
|
|
63
|
+
modules: stats_json.modules,
|
|
64
|
+
chunkDependencies,
|
|
65
|
+
functionRemotes: this.allArgumentsUsed,
|
|
66
|
+
target: this._options.target ?? getPlatformFromStats,
|
|
67
|
+
};
|
|
68
|
+
let graphData;
|
|
69
|
+
try {
|
|
70
|
+
graphData = (0, convert_to_graph_1.convertToGraph)(rawData, !!this._options.standalone);
|
|
71
|
+
(0, zephyr_edge_contract_1.ze_log)('\n\n', 'graphData', graphData, '\n\n');
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
console.warn('Error during dashboard data processing..');
|
|
75
|
+
console.warn(err);
|
|
76
|
+
}
|
|
77
|
+
if (!graphData) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return graphData;
|
|
81
|
+
}
|
|
82
|
+
// TODO: add notes on why we need these and what does these do
|
|
83
|
+
getRemoteEntryChunk(stats, FederationPluginOptions) {
|
|
84
|
+
if (!stats.chunks)
|
|
85
|
+
return;
|
|
86
|
+
// TODO: print all chunk name and see if it has the bundle name or actual remote name. in Rspack this field would return in remote application but won't return in host application due to Rspack's data structure - need external PR to fix
|
|
87
|
+
return stats.chunks.find((chunk) => chunk.names?.find((name) => name === FederationPluginOptions.name));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Return { "main": [{...dep1Details}, {...dep2Details}], "vendor": [{...dep3Details}],
|
|
91
|
+
*
|
|
92
|
+
* 1. Useful for dynamic imports - object generated could inform the bundler or runtime loader about which chunks are needed for specific
|
|
93
|
+
* part of the app, enabling better performance optimization 1.1 if a chunk representing a React component dynamically loads, this
|
|
94
|
+
* dependency graph can help the runtime understand what other chunks need to be loaded alongside it.
|
|
95
|
+
* 2. Optimized loading and caching: By mapping chunk dependencies, this function supports advanced optimizations like caching. Chunks that
|
|
96
|
+
* haven’t changed between builds can be cached separately, reducing the need for users to download unchanged code.
|
|
97
|
+
*
|
|
98
|
+
* }
|
|
99
|
+
*/
|
|
100
|
+
getChunkDependencies(validChunkArray) {
|
|
101
|
+
return validChunkArray.reduce((acc, chunk) => {
|
|
102
|
+
// getAllReferencedChunks is used in rspack to understand the dependencies between chunks, the information is crucial for code splitting, lazy loading and ensuring all necessary code is included in final bundle
|
|
103
|
+
// Return a `Set` <key:chunk, value:compilation>
|
|
104
|
+
// to ensure no duplicate data is included
|
|
105
|
+
// source: https://github.com/web-infra-dev/rspack/blob/9c56263c9d731923031f17ed20dae180c99256a7/packages/rspack/src/Chunk.ts#L151
|
|
106
|
+
const subset = chunk.getAllReferencedChunks();
|
|
107
|
+
const stringifiableChunk = Array.from(subset).map((sub) => {
|
|
108
|
+
const cleanSet = Object.getOwnPropertyNames(sub).reduce((acc, key) => {
|
|
109
|
+
// TODO: Is this the correct chunk to be excluded ?
|
|
110
|
+
if (key === '_groups')
|
|
111
|
+
return acc;
|
|
112
|
+
return Object.assign(acc, { [key]: sub[key] });
|
|
113
|
+
}, {});
|
|
114
|
+
return this.mapToObjectRec(cleanSet);
|
|
115
|
+
});
|
|
116
|
+
return Object.assign(acc, {
|
|
117
|
+
[`${chunk.id}`]: stringifiableChunk,
|
|
118
|
+
});
|
|
119
|
+
}, {});
|
|
120
|
+
}
|
|
121
|
+
buildVendorFederationMap(liveStats) {
|
|
122
|
+
// calling it "vendor", it's actually dependencies in module federation
|
|
123
|
+
const vendorFederation = {};
|
|
124
|
+
let packageJson;
|
|
125
|
+
if (this._options.packageJsonPath) {
|
|
126
|
+
try {
|
|
127
|
+
packageJson = require(this._options.packageJsonPath);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
throw new zephyr_edge_contract_2.ZephyrError(zephyr_edge_contract_2.ZeErrors.ERR_PACKAGE_JSON_NOT_FOUND, {
|
|
131
|
+
data: {
|
|
132
|
+
process: `While finding dependencies in package.json.`,
|
|
133
|
+
cause: e,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const initialPath = liveStats.compilation.options.context?.split(path_1.sep);
|
|
140
|
+
packageJson = (0, federation_plugin_get_package_json_1.find_package_json)(initialPath);
|
|
141
|
+
}
|
|
142
|
+
if (packageJson) {
|
|
143
|
+
// TODO: make sure all passed in value are correct
|
|
144
|
+
vendorFederation.dependencies = (0, compute_dependencies_1.default)({
|
|
145
|
+
exclude: [],
|
|
146
|
+
ignoreVersion: false,
|
|
147
|
+
packageJson,
|
|
148
|
+
shareFrom: ['dependencies'],
|
|
149
|
+
ignorePatchVersion: false,
|
|
150
|
+
});
|
|
151
|
+
vendorFederation.devDependencies = (0, compute_dependencies_1.default)({
|
|
152
|
+
exclude: [],
|
|
153
|
+
ignoreVersion: false,
|
|
154
|
+
packageJson,
|
|
155
|
+
shareFrom: ['devDependencies'],
|
|
156
|
+
ignorePatchVersion: false,
|
|
157
|
+
});
|
|
158
|
+
vendorFederation.optionalDependencies = (0, compute_dependencies_1.default)({
|
|
159
|
+
exclude: [],
|
|
160
|
+
ignoreVersion: false,
|
|
161
|
+
packageJson,
|
|
162
|
+
shareFrom: ['optionalDependencies'],
|
|
163
|
+
ignorePatchVersion: false,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return vendorFederation;
|
|
167
|
+
}
|
|
168
|
+
// Clean up the Chunks to a clear object with keys
|
|
169
|
+
mapToObjectRec(m) {
|
|
170
|
+
const lo = {};
|
|
171
|
+
for (const [key, value] of Object.entries(m)) {
|
|
172
|
+
if (value instanceof Map && value.size > 0) {
|
|
173
|
+
lo[key] = this.mapToObjectRec(value);
|
|
174
|
+
}
|
|
175
|
+
else if (value instanceof Set && value.size > 0) {
|
|
176
|
+
lo[key] = this.mapToObjectRec(Array.from(value));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
lo[key] = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return lo;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* In a remote application, this function is used to find all the chunks that are referenced by the remote entry chunk It won't return
|
|
186
|
+
* anything from HostApp
|
|
187
|
+
*/
|
|
188
|
+
buildValidChunkArray(liveStats, FederationPluginOptions) {
|
|
189
|
+
if (!FederationPluginOptions.name)
|
|
190
|
+
return [];
|
|
191
|
+
const namedChunkRefs = liveStats.compilation.namedChunks.get(FederationPluginOptions.name);
|
|
192
|
+
if (!namedChunkRefs)
|
|
193
|
+
return [];
|
|
194
|
+
const AllReferencedChunksByRemote = namedChunkRefs.getAllReferencedChunks();
|
|
195
|
+
const validChunkArray = [];
|
|
196
|
+
Array.from(AllReferencedChunksByRemote).map((chunk) => {
|
|
197
|
+
if (chunk.id !== FederationPluginOptions.name) {
|
|
198
|
+
validChunkArray.push(chunk);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
return validChunkArray;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* We are doing this because the filename in React Native is the actual JS bundle, "How we understand the filename is different in react
|
|
205
|
+
* native" - filename would be at the end of the URL modified in get_mf_config.ts If we don't attach the remote bundle name to metadata,
|
|
206
|
+
* we will have no track record of the actual bundle when we need it later -- this is RePack specific.
|
|
207
|
+
*/
|
|
208
|
+
attach_remote_bundle_name_to_metadata() {
|
|
209
|
+
// TODO: not sure if this error would break the build. Silently log it for now
|
|
210
|
+
if (!this.FederationPluginOptions.bundle_name) {
|
|
211
|
+
console.warn(zephyr_edge_contract_2.ZeErrors.ERR_MF_CONFIG_MISSING_FILENAME);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return { remote_bundle_name: this.FederationPluginOptions.bundle_name };
|
|
215
|
+
}
|
|
216
|
+
// For debugging purpose?
|
|
217
|
+
async postDashboardData(dashData // TODO: need stronger types
|
|
218
|
+
) {
|
|
219
|
+
throw new Error('not implemented, override it');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.FederationDashboardPlugin = FederationDashboardPlugin;
|
|
223
|
+
//# sourceMappingURL=federation-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation-plugin.js","sourceRoot":"","sources":["../../../src/lib/federation-graph/feder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C,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,+BAAQ,CAAC,8BAA8B,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;QAED,OAAO,EAAE,kBAAkB,EAAE,IAAI,CAAC,uBAAuB,CAAC,WAAW,EAAE,CAAC;IAC1E,CAAC;IAED,yBAAyB;IACzB,KAAK,CAAC,iBAAiB,CACrB,QAAa,CAAC,4BAA4B;;QAE1C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;CACF;AAxQD,8DAwQC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddRuntimeRequirementToPromiseExternal = void 0;
|
|
4
|
+
class AddRuntimeRequirementToPromiseExternal {
|
|
5
|
+
apply(compiler) {
|
|
6
|
+
//
|
|
7
|
+
compiler.hooks.compilation.tap('AddRuntimeRequirementToPromiseExternal', (compilation) => {
|
|
8
|
+
// TODO: access runtime global
|
|
9
|
+
const { RuntimeGlobals } = compiler.rspack;
|
|
10
|
+
// compilation.outputOptions.trustedTypes are used in browser environment to ensure XSS attack, this won't be useful in React Native
|
|
11
|
+
// reference: https://github.com/web-infra-dev/rspack/blob/52d7dcd48df764674f50e65b51297a7a697c15e7/packages/rspack/src/config/types.ts#L306
|
|
12
|
+
if (compilation.outputOptions.trustedTypes) {
|
|
13
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap('AddRuntimeRequirementToPromiseExternal', (chunk, set) => {
|
|
14
|
+
if (chunk.externalType === 'promise') {
|
|
15
|
+
set.add(RuntimeGlobals.loadScript);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// even if `trustedTypes` don't exists, there isn't an external type, load the script anyways
|
|
20
|
+
// TODO: verify if this works
|
|
21
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap('AddRuntimeRequirementToPromiseExternal', (chunk, set) => {
|
|
22
|
+
set.add(RuntimeGlobals.loadScript);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AddRuntimeRequirementToPromiseExternal = AddRuntimeRequirementToPromiseExternal;
|
|
28
|
+
//# sourceMappingURL=runtime-requirement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-requirement.js","sourceRoot":"","sources":["../../../src/lib/federation-graph/runtime-requirement.ts"],"names":[],"mappings":";;;AAEA,MAAa,sCAAsC;IACjD,KAAK,CAAC,QAAkB;QACtB,EAAE;QACF,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,wCAAwC,EAAE,CAAC,WAAwB,EAAE,EAAE;YACpG,8BAA8B;YAC9B,MAAM,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC3C,oIAAoI;YACpI,4IAA4I;YAC5I,IAAI,WAAW,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;gBAC3C,WAAW,CAAC,KAAK,CAAC,iCAAiC,CAAC,GAAG,CACrD,wCAAwC,EACxC,CAAC,KAAwC,EAAE,GAAG,EAAE,EAAE;oBAChD,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;wBACrC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC,CACF,CAAC;YACJ,CAAC;YAED,6FAA6F;YAC7F,6BAA6B;YAC7B,WAAW,CAAC,KAAK,CAAC,iCAAiC,CAAC,GAAG,CAAC,wCAAwC,EAAE,CAAC,KAAY,EAAE,GAAG,EAAE,EAAE;gBACtH,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,wFA0BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TopLevelPackage } from '../../../type/federation-plugin-options';
|
|
2
|
+
import { LocalPackageJson } from 'zephyr-edge-contract';
|
|
3
|
+
export interface ConvertedDependencies {
|
|
4
|
+
dependencies?: LocalPackageJson[];
|
|
5
|
+
devDependencies?: LocalPackageJson[];
|
|
6
|
+
optionalDependencies?: LocalPackageJson[];
|
|
7
|
+
}
|
|
8
|
+
export type NpmModules = Map<string, Record<string, LocalPackageJson>>;
|
|
9
|
+
export declare function convertDependencies(params: {
|
|
10
|
+
package: TopLevelPackage;
|
|
11
|
+
npmModules: NpmModules;
|
|
12
|
+
}): ConvertedDependencies;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertDependencies = void 0;
|
|
4
|
+
function convertDependencies(params) {
|
|
5
|
+
return {
|
|
6
|
+
dependencies: convertDeps(params.npmModules, params.package.dependencies),
|
|
7
|
+
devDependencies: convertDeps(params.npmModules, params.package.devDependencies),
|
|
8
|
+
optionalDependencies: convertDeps(params.npmModules, params.package.optionalDependencies),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.convertDependencies = convertDependencies;
|
|
12
|
+
function convertDeps(npmModules, deps) {
|
|
13
|
+
if (!deps)
|
|
14
|
+
return;
|
|
15
|
+
return Object.entries(deps).map(([version, name]) => {
|
|
16
|
+
const dataFromGraph = npmModules.get(name);
|
|
17
|
+
const versionVal = version.replace(`${name}-`, '');
|
|
18
|
+
if (dataFromGraph) {
|
|
19
|
+
const foundInGraph = Object.values(dataFromGraph).find((depData) => depData.version.startsWith(versionVal));
|
|
20
|
+
if (foundInGraph) {
|
|
21
|
+
const { name, version, license, size } = foundInGraph;
|
|
22
|
+
return { name, version, license, size };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
name,
|
|
27
|
+
version: versionVal,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=convert-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-dependencies.js","sourceRoot":"","sources":["../../../../src/lib/federation-graph/utils/convert-dependencies.ts"],"names":[],"mappings":";;;AAWA,SAAgB,mBAAmB,CAAC,MAA4D;IAC9F,OAAO;QACL,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;QACzE,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;QAC/E,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC;KAC1F,CAAC;AACJ,CAAC;AAND,kDAMC;AAED,SAAS,WAAW,CAAC,UAAsB,EAAE,IAA6B;IACxE,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClD,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE3C,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;QAEnD,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YAE5G,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;gBACtD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC1C,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI;YACJ,OAAO,EAAE,UAAU;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToGraph = void 0;
|
|
4
|
+
const convert_dependencies_1 = require("./convert-dependencies");
|
|
5
|
+
const module_part_one_1 = require("./module-part-one");
|
|
6
|
+
const module_part_two_1 = require("./module-part-two");
|
|
7
|
+
const process_function_remotes_1 = require("./process-function-remotes");
|
|
8
|
+
function convertToGraph(params, standalone) {
|
|
9
|
+
const { name, federationRemoteEntry, modules, topLevelPackage, metadata, versionData, environment, version, posted, group, functionRemotes, sha, buildHash, } = params;
|
|
10
|
+
const { consumes, modulesObj, npmModules } = (0, module_part_one_1.modulePartOne)(modules);
|
|
11
|
+
const convertedDeps = (0, convert_dependencies_1.convertDependencies)({
|
|
12
|
+
package: topLevelPackage,
|
|
13
|
+
npmModules,
|
|
14
|
+
});
|
|
15
|
+
const { overrides } = (0, module_part_two_1.modulePartTwo)({
|
|
16
|
+
name,
|
|
17
|
+
modules,
|
|
18
|
+
modulesObj,
|
|
19
|
+
convertedDeps,
|
|
20
|
+
});
|
|
21
|
+
(0, process_function_remotes_1.processFunctionRemotes)({ functionRemotes, consumes });
|
|
22
|
+
const sourceUrl = metadata?.source?.url ?? '';
|
|
23
|
+
const remote = metadata?.remote ?? '';
|
|
24
|
+
return {
|
|
25
|
+
...convertedDeps,
|
|
26
|
+
id: name,
|
|
27
|
+
name: name,
|
|
28
|
+
remote,
|
|
29
|
+
metadata,
|
|
30
|
+
versionData,
|
|
31
|
+
overrides: Object.values(overrides),
|
|
32
|
+
consumes: consumes.map((con) => ({
|
|
33
|
+
...con,
|
|
34
|
+
usedIn: Array.from(con.usedIn.values()).map((file) => ({
|
|
35
|
+
file,
|
|
36
|
+
url: `${sourceUrl}/${file}`,
|
|
37
|
+
})),
|
|
38
|
+
})),
|
|
39
|
+
modules: Object.values(modulesObj).map((mod) => ({
|
|
40
|
+
...mod,
|
|
41
|
+
requires: Array.from(mod.requires.values()).filter((value) => typeof value === 'string'),
|
|
42
|
+
})),
|
|
43
|
+
environment,
|
|
44
|
+
version,
|
|
45
|
+
posted,
|
|
46
|
+
group,
|
|
47
|
+
sha,
|
|
48
|
+
buildHash,
|
|
49
|
+
target: params.target,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.convertToGraph = convertToGraph;
|
|
53
|
+
//# sourceMappingURL=convert-to-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-to-graph.js","sourceRoot":"","sources":["../../../../src/lib/federation-graph/utils/convert-to-graph.ts"],"names":[],"mappings":";;;AAEA,iEAA6D;AAC7D,uDAAkD;AAClD,uDAAkD;AAClD,yEAAoE;AAEpE,SAAgB,cAAc,CAAC,MAA4B,EAAE,UAAoB;IAC/E,MAAM,EACJ,IAAI,EACJ,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,eAAe,EACf,GAAG,EACH,SAAS,GACV,GAAG,MAAM,CAAC;IAEX,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAA,+BAAa,EAAC,OAAO,CAAC,CAAC;IAEpE,MAAM,aAAa,GAAG,IAAA,0CAAmB,EAAC;QACxC,OAAO,EAAE,eAAe;QACxB,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAa,EAAC;QAClC,IAAI;QACJ,OAAO;QACP,UAAU;QACV,aAAa;KACd,CAAC,CAAC;IAEH,IAAA,iDAAsB,EAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEtD,MAAM,SAAS,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC;IAEtC,OAAO;QACL,GAAG,aAAa;QAChB,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,IAAI;QACV,MAAM;QACN,QAAQ;QACR,WAAW;QACX,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/B,GAAG,GAAG;YACN,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACrD,IAAI;gBACJ,GAAG,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE;aAC5B,CAAC,CAAC;SACJ,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/C,GAAG,GAAG;YACN,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;SACzF,CAAC,CAAC;QACH,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,GAAG;QACH,SAAS;QACT,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC;AA/DD,wCA+DC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LocalPackageJson } from 'zephyr-edge-contract';
|
|
2
|
+
import { TopLevelPackage } from '../../../type/federation-plugin-options';
|
|
3
|
+
export interface ConvertedDependencies {
|
|
4
|
+
dependencies?: LocalPackageJson[];
|
|
5
|
+
devDependencies?: LocalPackageJson[];
|
|
6
|
+
optionalDependencies?: LocalPackageJson[];
|
|
7
|
+
}
|
|
8
|
+
export type NpmModules = Map<string, Record<string, LocalPackageJson>>;
|
|
9
|
+
export declare function convertDependencies(params: {
|
|
10
|
+
package: TopLevelPackage;
|
|
11
|
+
npmModules: NpmModules;
|
|
12
|
+
}): ConvertedDependencies;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertDependencies = void 0;
|
|
4
|
+
function convertDependencies(params) {
|
|
5
|
+
return {
|
|
6
|
+
dependencies: convertDeps(params.npmModules, params.package.dependencies),
|
|
7
|
+
devDependencies: convertDeps(params.npmModules, params.package.devDependencies),
|
|
8
|
+
optionalDependencies: convertDeps(params.npmModules, params.package.optionalDependencies),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.convertDependencies = convertDependencies;
|
|
12
|
+
function convertDeps(npmModules, deps) {
|
|
13
|
+
if (!deps)
|
|
14
|
+
return;
|
|
15
|
+
return Object.entries(deps).map(([version, name]) => {
|
|
16
|
+
const dataFromGraph = npmModules.get(name);
|
|
17
|
+
const versionVal = version.replace(`${name}-`, '');
|
|
18
|
+
if (dataFromGraph) {
|
|
19
|
+
const foundInGraph = Object.values(dataFromGraph).find((depData) => depData.version.startsWith(versionVal));
|
|
20
|
+
if (foundInGraph) {
|
|
21
|
+
const { name, version, license, size } = foundInGraph;
|
|
22
|
+
return { name, version, license, size };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
name,
|
|
27
|
+
version: versionVal,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=converted-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converted-dependencies.js","sourceRoot":"","sources":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AAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLicenses = void 0;
|
|
4
|
+
function getLicenses(packageJson) {
|
|
5
|
+
if (Array.isArray(packageJson.licenses)) {
|
|
6
|
+
return packageJson.licenses.map((license) => license.type).join(', ');
|
|
7
|
+
}
|
|
8
|
+
if (typeof packageJson.licenses !== 'string' && packageJson.licenses?.type) {
|
|
9
|
+
return packageJson.licenses.type;
|
|
10
|
+
}
|
|
11
|
+
if (typeof packageJson.license !== 'string' && packageJson.license?.type) {
|
|
12
|
+
return packageJson.license.type;
|
|
13
|
+
}
|
|
14
|
+
if (typeof packageJson.licenses === 'string') {
|
|
15
|
+
return packageJson.licenses;
|
|
16
|
+
}
|
|
17
|
+
if (typeof packageJson.license === 'string') {
|
|
18
|
+
return packageJson.license;
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
exports.getLicenses = getLicenses;
|
|
23
|
+
//# sourceMappingURL=get-licenses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-licenses.js","sourceRoot":"","sources":["../../../../src/lib/federation-graph/utils/get-licenses.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,WAA6B;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAyB,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IAED,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC3E,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ,IAAI,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;QACzE,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC7C,OAAO,WAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,OAAO;AACT,CAAC;AAtBD,kCAsBC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StatsModule } from '@rspack/core';
|
|
2
|
+
import { NpmModules } from './convert-dependencies';
|
|
3
|
+
import { ModuleObject } from './module-part-two';
|
|
4
|
+
export interface Consume {
|
|
5
|
+
consumingApplicationID: string;
|
|
6
|
+
applicationID: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
usedIn: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
interface ModulePartOneReturn {
|
|
11
|
+
consumes: Consume[];
|
|
12
|
+
modulesObj: Record<string, ModuleObject>;
|
|
13
|
+
npmModules: NpmModules;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Module analyzes the build statistics from Rspack to identify three key aspects of Module Federation. It calculate remote-module,
|
|
17
|
+
* container entry and node_modules
|
|
18
|
+
*
|
|
19
|
+
* 1. Remote Modules (remote-module) // TODO: this is broken needs to fix Tracks which modules are being consumed from other federated
|
|
20
|
+
* applications Maps the relationships between consuming applications and their remote dependencies Records where these remote modules
|
|
21
|
+
* are being used within the application
|
|
22
|
+
* 2. Container Entry (container entry) Processes the entry points exposed by the Module Federation container Creates a mapping of exposed
|
|
23
|
+
* modules and their file locations
|
|
24
|
+
* 3. Node Modules (node_modules) Collects information about third-party dependencies Gathers metadata like package versions, licenses, and
|
|
25
|
+
* sizes Helps track shared dependencies between federated applications
|
|
26
|
+
*
|
|
27
|
+
* @param modules - The stats object from @rspack/core to parse.
|
|
28
|
+
* @returns An object containing the consumes, modulesObj, and npmModules.
|
|
29
|
+
*/
|
|
30
|
+
export declare function modulePartOne(modules: StatsModule[] | undefined): ModulePartOneReturn;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modulePartOne = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const get_licenses_1 = require("./get-licenses");
|
|
7
|
+
function isString(value) {
|
|
8
|
+
return typeof value === 'string';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Module analyzes the build statistics from Rspack to identify three key aspects of Module Federation. It calculate remote-module,
|
|
12
|
+
* container entry and node_modules
|
|
13
|
+
*
|
|
14
|
+
* 1. Remote Modules (remote-module) // TODO: this is broken needs to fix Tracks which modules are being consumed from other federated
|
|
15
|
+
* applications Maps the relationships between consuming applications and their remote dependencies Records where these remote modules
|
|
16
|
+
* are being used within the application
|
|
17
|
+
* 2. Container Entry (container entry) Processes the entry points exposed by the Module Federation container Creates a mapping of exposed
|
|
18
|
+
* modules and their file locations
|
|
19
|
+
* 3. Node Modules (node_modules) Collects information about third-party dependencies Gathers metadata like package versions, licenses, and
|
|
20
|
+
* sizes Helps track shared dependencies between federated applications
|
|
21
|
+
*
|
|
22
|
+
* @param modules - The stats object from @rspack/core to parse.
|
|
23
|
+
* @returns An object containing the consumes, modulesObj, and npmModules.
|
|
24
|
+
*/
|
|
25
|
+
function modulePartOne(modules) {
|
|
26
|
+
const consumes = [];
|
|
27
|
+
const consumesByName = {};
|
|
28
|
+
const modulesObj = {};
|
|
29
|
+
const npmModules = new Map();
|
|
30
|
+
modules?.forEach((mod) => {
|
|
31
|
+
const { identifier, reasons, moduleType, nameForCondition, size } = mod;
|
|
32
|
+
if (!identifier)
|
|
33
|
+
return;
|
|
34
|
+
const data = identifier?.split(' ');
|
|
35
|
+
if (moduleType.includes('remote')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
/** When the moduleType is remote-module, we need to extract the applicationID and name from the data array */
|
|
39
|
+
if (moduleType === 'remote-module') {
|
|
40
|
+
// currently this criteria is not met, so this block is not executed
|
|
41
|
+
if (data?.length === 4 && isString(data[3]) && isString(data[2])) {
|
|
42
|
+
const name = data[3].replace('./', '');
|
|
43
|
+
/** We also check if the applicationID is a valid URL */
|
|
44
|
+
let applicationID = data[2].replace('webpack/container/reference/', '');
|
|
45
|
+
if (applicationID.includes('?')) {
|
|
46
|
+
applicationID = new URLSearchParams(applicationID.split('?')[1]).get('remoteName');
|
|
47
|
+
}
|
|
48
|
+
const consume = {
|
|
49
|
+
consumingApplicationID: name,
|
|
50
|
+
applicationID,
|
|
51
|
+
name,
|
|
52
|
+
usedIn: new Set(),
|
|
53
|
+
};
|
|
54
|
+
consumes.push(consume);
|
|
55
|
+
if (nameForCondition) {
|
|
56
|
+
consumesByName[nameForCondition] = consume;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (reasons) {
|
|
60
|
+
reasons.forEach(({ userRequest, resolvedModule }) => {
|
|
61
|
+
if (!userRequest || !consumesByName[userRequest] || !resolvedModule)
|
|
62
|
+
return;
|
|
63
|
+
const module = resolvedModule.replace('./', '');
|
|
64
|
+
consumesByName[userRequest].usedIn.add(module);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (data && data[0] === 'container' && data[1] === 'entry' && data[3]) {
|
|
69
|
+
JSON.parse(data[3]).forEach(([prefixedName, file]) => {
|
|
70
|
+
const name = prefixedName.replace('./', '');
|
|
71
|
+
modulesObj[file.import[0]] = {
|
|
72
|
+
id: `${name}:${name}`,
|
|
73
|
+
name,
|
|
74
|
+
applicationID: name,
|
|
75
|
+
requires: [],
|
|
76
|
+
file: file.import[0],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (nameForCondition && nameForCondition.includes('node_modules')) {
|
|
81
|
+
const contextArray = nameForCondition.split(node_path_1.sep);
|
|
82
|
+
const afterModule = nameForCondition.split('node_modules' + node_path_1.sep);
|
|
83
|
+
const search = afterModule[1] && afterModule[1].startsWith('@') ? 3 : 2;
|
|
84
|
+
contextArray.splice(contextArray.indexOf('node_modules') + search);
|
|
85
|
+
const context = contextArray.join(node_path_1.sep);
|
|
86
|
+
const packageJsonFile = (0, node_path_1.join)(context, 'package.json');
|
|
87
|
+
const packageJson = safe_read_package_json_sync(packageJsonFile);
|
|
88
|
+
if (packageJson) {
|
|
89
|
+
const existingPackage = npmModules.get(packageJson.name);
|
|
90
|
+
if (existingPackage) {
|
|
91
|
+
const existingReference = existingPackage[packageJson.version];
|
|
92
|
+
const data = {
|
|
93
|
+
name: packageJson.name,
|
|
94
|
+
version: packageJson.version,
|
|
95
|
+
homepage: packageJson.homepage,
|
|
96
|
+
license: (0, get_licenses_1.getLicenses)(packageJson),
|
|
97
|
+
size: (Number(existingReference.size) || 0) + (size ?? 0),
|
|
98
|
+
};
|
|
99
|
+
if (existingReference) {
|
|
100
|
+
Object.assign(existingReference, data);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
existingPackage[packageJson.version] = data;
|
|
104
|
+
}
|
|
105
|
+
npmModules.set(packageJson.name, existingPackage);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const newDep = {
|
|
109
|
+
[packageJson.version]: {
|
|
110
|
+
name: packageJson.name,
|
|
111
|
+
version: packageJson.version,
|
|
112
|
+
homepage: packageJson.homepage,
|
|
113
|
+
license: (0, get_licenses_1.getLicenses)(packageJson),
|
|
114
|
+
size,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
npmModules.set(packageJson.name, newDep);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return { consumes, modulesObj, npmModules };
|
|
123
|
+
}
|
|
124
|
+
exports.modulePartOne = modulePartOne;
|
|
125
|
+
function safe_read_package_json_sync(file_path) {
|
|
126
|
+
try {
|
|
127
|
+
return JSON.parse((0, node_fs_1.readFileSync)(file_path, { encoding: 'utf-8' }));
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=module-part-one.js.map
|