zephyr-repack-plugin 0.0.0-canary-20241122013202 → 0.0.0-canary-20241122025316
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/delegate-module/replace-remote-with-delegate.js +2 -2
- package/dist/delegate-module/replace-remote-with-delegate.js.map +1 -1
- package/dist/delegate-module/zephyr-delegate.d.ts +1 -6
- package/dist/delegate-module/zephyr-delegate.js +21 -70
- package/dist/delegate-module/zephyr-delegate.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/build-stats/get-build-stats.d.ts +1 -4
- package/dist/lib/build-stats/get-build-stats.js +19 -12
- package/dist/lib/build-stats/get-build-stats.js.map +1 -1
- package/dist/lib/dependency-resolution/replace-remote-with-delegates.js +7 -7
- package/dist/lib/dependency-resolution/replace-remote-with-delegates.js.map +1 -1
- package/dist/lib/federation-graph/compute-dependencies.js +10 -6
- package/dist/lib/federation-graph/compute-dependencies.js.map +1 -1
- package/dist/lib/federation-graph/compute-version.js.map +1 -1
- package/dist/lib/federation-graph/federation-plugin.d.ts +16 -11
- package/dist/lib/federation-graph/federation-plugin.js +26 -19
- package/dist/lib/federation-graph/federation-plugin.js.map +1 -1
- package/dist/lib/federation-graph/runtime-requirement.js.map +1 -1
- package/dist/lib/federation-graph/utils/convert-dependencies.js.map +1 -1
- package/dist/lib/federation-graph/utils/convert-to-graph.d.ts +1 -1
- package/dist/lib/federation-graph/utils/convert-to-graph.js +2 -2
- package/dist/lib/federation-graph/utils/convert-to-graph.js.map +1 -1
- package/dist/lib/federation-graph/utils/converted-dependencies.js.map +1 -1
- package/dist/lib/federation-graph/utils/get-licenses.js +3 -1
- package/dist/lib/federation-graph/utils/get-licenses.js.map +1 -1
- package/dist/lib/federation-graph/utils/module-part-one.d.ts +11 -9
- package/dist/lib/federation-graph/utils/module-part-one.js +15 -10
- package/dist/lib/federation-graph/utils/module-part-one.js.map +1 -1
- package/dist/lib/federation-graph/utils/module-part-two.d.ts +6 -4
- package/dist/lib/federation-graph/utils/module-part-two.js +26 -10
- package/dist/lib/federation-graph/utils/module-part-two.js.map +1 -1
- package/dist/lib/federation-graph/utils/process-function-remotes.d.ts +5 -3
- package/dist/lib/federation-graph/utils/process-function-remotes.js.map +1 -1
- package/dist/lib/{ze-agent/index.d.ts → repack_zephyr_agent.d.ts} +4 -3
- package/dist/lib/repack_zephyr_agent.js +58 -0
- package/dist/lib/repack_zephyr_agent.js.map +1 -0
- package/dist/lib/set-up-build-id.d.ts +2 -2
- package/dist/lib/set-up-build-id.js +11 -18
- package/dist/lib/set-up-build-id.js.map +1 -1
- package/dist/lib/set-up-build-stats-logging.d.ts +2 -2
- package/dist/lib/set-up-build-stats-logging.js +6 -8
- package/dist/lib/set-up-build-stats-logging.js.map +1 -1
- package/dist/lib/set-up-deploy.d.ts +2 -2
- package/dist/lib/set-up-deploy.js +6 -6
- package/dist/lib/set-up-deploy.js.map +1 -1
- package/dist/lib/utils/federation-plugin-get-package-json.js.map +1 -1
- package/dist/lib/utils/get-mf-config.d.ts +5 -2
- package/dist/lib/utils/get-mf-config.js +11 -11
- package/dist/lib/utils/get-mf-config.js.map +1 -1
- package/dist/lib/utils/get-platform.js +3 -1
- package/dist/lib/utils/get-platform.js.map +1 -1
- package/dist/lib/utils/plugin-search.d.ts +7 -1
- package/dist/lib/utils/plugin-search.js +4 -2
- package/dist/lib/utils/plugin-search.js.map +1 -1
- package/dist/lib/with-zephyr.js +21 -22
- package/dist/lib/with-zephyr.js.map +1 -1
- package/dist/lib/ze-repack-plugin.d.ts +6 -2
- package/dist/lib/ze-repack-plugin.js +2 -13
- package/dist/lib/ze-repack-plugin.js.map +1 -1
- package/dist/package.json +3 -2
- package/dist/type/convert-graph-params.d.ts +20 -5
- package/dist/type/federation-plugin-options.d.ts +2 -2
- package/dist/type/zephyr-internal-types.d.ts +3 -2
- package/package.json +4 -3
- package/dist/README.md +0 -3
- package/dist/lib/federation-graph/compute-shared-module.d.ts +0 -1
- package/dist/lib/federation-graph/compute-shared-module.js +0 -3
- package/dist/lib/federation-graph/compute-shared-module.js.map +0 -1
- package/dist/lib/ze-agent/index.js +0 -55
- package/dist/lib/ze-agent/index.js.map +0 -1
- package/dist/lib/ze-agent/lifecycle-events.d.ts +0 -2
- package/dist/lib/ze-agent/lifecycle-events.js +0 -20
- package/dist/lib/ze-agent/lifecycle-events.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replace_remote_with_delegate = void 0;
|
|
4
|
-
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
5
4
|
const delegate_module_template_1 = require("./delegate-module-template");
|
|
5
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
6
6
|
function replace_remote_with_delegate(deps) {
|
|
7
7
|
// prepare delegate function string template
|
|
8
8
|
const fnReplace = delegate_module_template_1.delegate_module_template.toString();
|
|
@@ -11,7 +11,7 @@ function replace_remote_with_delegate(deps) {
|
|
|
11
11
|
const strEnd = new RegExp(/;[^)}]+}$/);
|
|
12
12
|
const promiseNewPromise = fnReplace.replace(strStart, strNewStart).replace(strEnd, '');
|
|
13
13
|
const { application_uid, remote_entry_url, default_url, remote_name, library_type } = deps;
|
|
14
|
-
(0,
|
|
14
|
+
(0, zephyr_agent_1.ze_log)('replace_remote_with_delegate: ', {
|
|
15
15
|
application_uid: application_uid,
|
|
16
16
|
remote_entry_url: remote_entry_url,
|
|
17
17
|
remote_name: remote_name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-remote-with-delegate.js","sourceRoot":"","sources":["../../src/delegate-module/replace-remote-with-delegate.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"replace-remote-with-delegate.js","sourceRoot":"","sources":["../../src/delegate-module/replace-remote-with-delegate.ts"],"names":[],"mappings":";;;AACA,yEAAsE;AACtE,+CAAsC;AAEtC,SAAgB,4BAA4B,CAAC,IAAwB;IACnE,4CAA4C;IAC5C,MAAM,SAAS,GAAG,mDAAwB,CAAC,QAAQ,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,oCAAoC,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,qBAAqB,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEvF,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,GACjF,IAAI,CAAC;IAEP,IAAA,qBAAM,EAAC,gCAAgC,EAAE;QACvC,eAAe,EAAE,eAAe;QAChC,gBAAgB,EAAE,gBAAgB;QAClC,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,WAAW;QACxB,YAAY,EAAE,YAAY;KAC3B,CAAC,CAAC;IAEH,OAAO,iBAAiB;SACrB,OAAO,CAAC,qBAAqB,EAAE,eAAe,CAAC;SAC/C,OAAO,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;SACjD,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC;SACvC,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC;SACvC,OAAO,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;AAC/C,CAAC;AAzBD,oEAyBC"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import { DelegateConfig
|
|
2
|
-
export declare function resolve_remote_dependency({ application_uid, version, platform, }: {
|
|
3
|
-
application_uid: string;
|
|
4
|
-
version: string;
|
|
5
|
-
platform: DelegateConfig['target'];
|
|
6
|
-
}): Promise<ResolvedDependency>;
|
|
1
|
+
import { DelegateConfig } from '../type/zephyr-internal-types';
|
|
7
2
|
export declare function replace_remote_in_mf_config(mf_config: any, config: DelegateConfig): Promise<void>;
|
|
@@ -1,72 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replace_remote_in_mf_config =
|
|
3
|
+
exports.replace_remote_in_mf_config = void 0;
|
|
4
4
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
5
|
-
const
|
|
6
|
-
const zephyr_edge_contract_3 = require("zephyr-edge-contract");
|
|
7
|
-
async function resolve_remote_dependency({ application_uid, version, platform, }) {
|
|
8
|
-
(0, zephyr_edge_contract_3.ze_log)('resolve_remote_dependency.version:', version);
|
|
9
|
-
const resolveDependency = new URL(`${zephyr_edge_contract_2.ze_api_gateway.resolve}/${encodeURIComponent(application_uid)}/${encodeURIComponent(version)}`, (0, zephyr_edge_contract_2.ZE_API_ENDPOINT)());
|
|
10
|
-
const searchParams = new URLSearchParams();
|
|
11
|
-
platform && searchParams.set('build_target', platform);
|
|
12
|
-
resolveDependency.search = searchParams.toString();
|
|
13
|
-
(0, zephyr_edge_contract_3.ze_log)('trying to resolve dependencies via URL: ', resolveDependency);
|
|
14
|
-
const [appName, projectName, orgName] = application_uid.split('.');
|
|
15
|
-
try {
|
|
16
|
-
const token = await (0, zephyr_edge_contract_2.getToken)();
|
|
17
|
-
const res = await fetch(resolveDependency, {
|
|
18
|
-
method: 'GET',
|
|
19
|
-
headers: {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
Authorization: 'Bearer ' + token,
|
|
22
|
-
Accept: 'application/json',
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
if (!res.ok) {
|
|
26
|
-
(0, zephyr_edge_contract_3.ze_log)({ 'error in resolve_remote_dependency': await res.json().catch(() => res.text()) });
|
|
27
|
-
throw new zephyr_edge_contract_2.ZephyrError(zephyr_edge_contract_2.ZeErrors.ERR_RESOLVE_REMOTES, {
|
|
28
|
-
appUid: application_uid,
|
|
29
|
-
appName,
|
|
30
|
-
projectName,
|
|
31
|
-
orgName,
|
|
32
|
-
data: {
|
|
33
|
-
url: resolveDependency.toString(),
|
|
34
|
-
version,
|
|
35
|
-
error: await res.json().catch(() => res.text()),
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const response = (await res.json());
|
|
40
|
-
if (response.value) {
|
|
41
|
-
(0, zephyr_edge_contract_3.ze_log)('Response from resolve dependency: ', response.value);
|
|
42
|
-
return response.value;
|
|
43
|
-
}
|
|
44
|
-
throw new zephyr_edge_contract_2.ZephyrError(zephyr_edge_contract_2.ZeErrors.ERR_RESOLVE_REMOTES, {
|
|
45
|
-
appUid: application_uid,
|
|
46
|
-
appName,
|
|
47
|
-
projectName,
|
|
48
|
-
orgName,
|
|
49
|
-
data: { version, response },
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (cause) {
|
|
53
|
-
(0, zephyr_edge_contract_3.ze_log)({ 'error in resolve_remote_dependency': cause });
|
|
54
|
-
throw new zephyr_edge_contract_2.ZephyrError(zephyr_edge_contract_2.ZeErrors.ERR_CANNOT_RESOLVE_APP_NAME_WITH_VERSION, {
|
|
55
|
-
data: { version },
|
|
56
|
-
cause,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.resolve_remote_dependency = resolve_remote_dependency;
|
|
5
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
61
6
|
async function replace_remote_in_mf_config(mf_config, config) {
|
|
62
7
|
// In Repack.plugins.ModuleFederationPlugin, the config is exposed under `config`
|
|
63
8
|
// !! don't create a shallow copy other than pointing to the reference in javascript
|
|
64
9
|
const mfConfig = mf_config.config;
|
|
65
|
-
(0,
|
|
10
|
+
(0, zephyr_agent_1.ze_log)('replace_remote_in_mf_config', mfConfig);
|
|
66
11
|
if (!mfConfig.remotes) {
|
|
67
12
|
return;
|
|
68
13
|
}
|
|
69
|
-
(0,
|
|
14
|
+
(0, zephyr_agent_1.ze_log)('replace_remote_in_mf_config.mfPlugin', mfConfig);
|
|
70
15
|
// Replace remotes with delegate function
|
|
71
16
|
await Promise.all(Object.keys(mfConfig.remotes).map(async (key) => {
|
|
72
17
|
const [app_name, project_name, org_name] = key.split('.', 3);
|
|
@@ -74,30 +19,33 @@ async function replace_remote_in_mf_config(mf_config, config) {
|
|
|
74
19
|
// Does remote key contain localhost?
|
|
75
20
|
// step 1:if the remote is a local path, we resolve it
|
|
76
21
|
if (mfConfig.remotes[key].includes('localhost')) {
|
|
77
|
-
const application_uid = (0, zephyr_edge_contract_1.
|
|
22
|
+
const application_uid = (0, zephyr_edge_contract_1.createApplicationUid)({
|
|
78
23
|
org: org_name ?? config.org,
|
|
79
24
|
project: project_name ?? config.project,
|
|
80
25
|
name: app_name,
|
|
81
26
|
});
|
|
82
|
-
const [
|
|
27
|
+
const [error, resolvedDependency] = await zephyr_edge_contract_1.ZeUtils.PromiseTuple((0, zephyr_agent_1.resolve_remote_dependency)({
|
|
83
28
|
application_uid: application_uid,
|
|
84
29
|
version: mfConfig.remotes[key],
|
|
85
30
|
platform: config.target,
|
|
86
31
|
}));
|
|
87
32
|
// If couldn't resolve remote dependency, skip replacing it
|
|
88
|
-
if (
|
|
33
|
+
if (error || !resolvedDependency) {
|
|
89
34
|
return;
|
|
90
35
|
}
|
|
91
36
|
resolvedDependency.library_type = mfConfig?.library?.type ?? 'self';
|
|
92
37
|
const [v_app] = mfConfig.remotes[key]?.split('@') ?? [];
|
|
93
38
|
if (v_app) {
|
|
94
|
-
resolvedDependency.remote_entry_url = [
|
|
95
|
-
|
|
39
|
+
resolvedDependency.remote_entry_url = [
|
|
40
|
+
v_app,
|
|
41
|
+
resolvedDependency.remote_entry_url,
|
|
42
|
+
].join('@');
|
|
43
|
+
(0, zephyr_agent_1.ze_log)({
|
|
44
|
+
' resolvedDependency.remote_entry_url ': resolvedDependency.remote_entry_url,
|
|
45
|
+
});
|
|
96
46
|
}
|
|
97
|
-
resolvedDependency.remote_name = key;
|
|
98
|
-
// mfConfig.remotes[key] = await replace_remote_with_delegate(resolvedDependency);
|
|
99
47
|
mfConfig.remotes[key] = resolvedDependency.remote_entry_url;
|
|
100
|
-
(0,
|
|
48
|
+
(0, zephyr_agent_1.ze_log)('mfConfig: ', mfConfig, 'key: ', resolvedDependency);
|
|
101
49
|
}
|
|
102
50
|
// step 2: If the remote is not a local path (user wants a custom, environment-specific remote), we can skip replacing it
|
|
103
51
|
return;
|
|
@@ -106,14 +54,14 @@ async function replace_remote_in_mf_config(mf_config, config) {
|
|
|
106
54
|
exports.replace_remote_in_mf_config = replace_remote_in_mf_config;
|
|
107
55
|
function replace_remote_with_delegate(deps) {
|
|
108
56
|
// prepare delegate function string template
|
|
109
|
-
(0,
|
|
57
|
+
(0, zephyr_agent_1.ze_log)('start replacing remote with delegate...', deps);
|
|
110
58
|
const fnReplace = delegate_module_template.toString();
|
|
111
59
|
const strStart = new RegExp(/^function[\W\S]+return new Promise/);
|
|
112
60
|
const strNewStart = `promise new Promise`;
|
|
113
61
|
const strEnd = new RegExp(/;[^)}]+}$/);
|
|
114
62
|
const promiseNewPromise = fnReplace.replace(strStart, strNewStart).replace(strEnd, '');
|
|
115
63
|
const { application_uid, remote_entry_url, default_url, remote_name, library_type } = deps;
|
|
116
|
-
(0,
|
|
64
|
+
(0, zephyr_agent_1.ze_log)('replace_remote_with_delegate: ', {
|
|
117
65
|
application_uid: application_uid,
|
|
118
66
|
remote_entry_url: remote_entry_url,
|
|
119
67
|
remote_name: remote_name,
|
|
@@ -152,7 +100,10 @@ function delegate_module_template() {
|
|
|
152
100
|
if (typeof remoteUrl !== 'string')
|
|
153
101
|
return;
|
|
154
102
|
let _win = {};
|
|
155
|
-
_win =
|
|
103
|
+
_win =
|
|
104
|
+
globalThis !== undefined
|
|
105
|
+
? globalThis
|
|
106
|
+
: global;
|
|
156
107
|
const ScriptManager = __webpack_require__.repack.shared.scriptManager;
|
|
157
108
|
ScriptManager.addResolver(
|
|
158
109
|
// @ts-expect-error TODO fix await
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zephyr-delegate.js","sourceRoot":"","sources":["../../src/delegate-module/zephyr-delegate.ts"],"names":[],"mappings":";;;AAAA,+DAAqE;
|
|
1
|
+
{"version":3,"file":"zephyr-delegate.js","sourceRoot":"","sources":["../../src/delegate-module/zephyr-delegate.ts"],"names":[],"mappings":";;;AAAA,+DAAqE;AAErE,+CAAiE;AAE1D,KAAK,UAAU,2BAA2B,CAC/C,SAAc,EACd,MAAsB;IAEtB,iFAAiF;IAEjF,oFAAoF;IAEpF,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC;IAElC,IAAA,qBAAM,EAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;IAEhD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,IAAA,qBAAM,EAAC,sCAAsC,EAAE,QAAQ,CAAC,CAAC;IAEzD,yCAAyC;IACzC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC9C,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAE7D,iCAAiC;QACjC,qCAAqC;QAErC,sDAAsD;QACtD,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAChD,MAAM,eAAe,GAAG,IAAA,2CAAoB,EAAC;gBAC3C,GAAG,EAAE,QAAQ,IAAI,MAAM,CAAC,GAAG;gBAC3B,OAAO,EAAE,YAAY,IAAI,MAAM,CAAC,OAAO;gBACvC,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YAEH,MAAM,CAAC,KAAK,EAA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1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.withZephyr = void 0;
|
|
4
|
+
var with_zephyr_1 = require("./lib/with-zephyr");
|
|
5
|
+
Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return with_zephyr_1.withZephyr; } });
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,yGAAA,UAAU,OAAA"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { ZephyrAgentProps } from '../../type/zephyr-internal-types';
|
|
2
2
|
import { ZephyrBuildStats } from 'zephyr-edge-contract';
|
|
3
|
-
export declare function getBuildStats({ stats, stats_json, pluginOptions,
|
|
4
|
-
EDGE_URL: string;
|
|
5
|
-
PLATFORM?: string;
|
|
6
|
-
}): ZephyrBuildStats;
|
|
3
|
+
export declare function getBuildStats({ stats, stats_json, pluginOptions, }: ZephyrAgentProps): Promise<ZephyrBuildStats>;
|
|
@@ -5,8 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const isCI = tslib_1.__importStar(require("is-ci"));
|
|
6
6
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
7
7
|
const federation_plugin_1 = require("../federation-graph/federation-plugin");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
9
|
+
async function getBuildStats({ stats, stats_json, pluginOptions, }) {
|
|
10
|
+
(0, zephyr_agent_1.ze_log)('Started getting build stats...');
|
|
10
11
|
const dashboardPlugin = new federation_plugin_1.FederationDashboardPlugin({
|
|
11
12
|
app: pluginOptions.app,
|
|
12
13
|
git: pluginOptions.git,
|
|
@@ -15,26 +16,31 @@ function getBuildStats({ stats, stats_json, pluginOptions, EDGE_URL, PLATFORM, }
|
|
|
15
16
|
},
|
|
16
17
|
target: pluginOptions.target,
|
|
17
18
|
});
|
|
18
|
-
(0,
|
|
19
|
+
(0, zephyr_agent_1.ze_log)('process webpack graph...');
|
|
19
20
|
const convertedGraph = dashboardPlugin.processRspackGraph({
|
|
20
21
|
stats,
|
|
21
22
|
stats_json,
|
|
22
23
|
pluginOptions,
|
|
23
24
|
});
|
|
24
25
|
if (!convertedGraph) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_CONVERT_GRAPH_TO_DASHBOARD);
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
const build_id = await pluginOptions.zephyr_engine.build_id;
|
|
29
|
+
const app_config = await pluginOptions.zephyr_engine.application_configuration;
|
|
30
|
+
const version = (0, zephyr_edge_contract_1.flatCreateSnapshotId)({
|
|
31
|
+
org: pluginOptions.app.org,
|
|
32
|
+
project: pluginOptions.app.project,
|
|
33
|
+
name: pluginOptions.app.name,
|
|
34
|
+
username: app_config.username,
|
|
35
|
+
buildId: build_id,
|
|
36
|
+
});
|
|
28
37
|
const remote_name = pluginOptions.mfConfig?.filename ?? 'mf-manifest.json';
|
|
29
38
|
const { app, git } = pluginOptions;
|
|
30
39
|
const data_overrides = {
|
|
31
40
|
id: pluginOptions.application_uid,
|
|
32
41
|
name: pluginOptions.mfConfig?.name,
|
|
33
|
-
edge: { url: EDGE_URL },
|
|
34
|
-
|
|
35
|
-
platform: PLATFORM,
|
|
36
|
-
// type: TYPE,
|
|
37
|
-
app: Object.assign({}, app, { buildId: pluginOptions.zeConfig.buildId }),
|
|
42
|
+
edge: { url: app_config.EDGE_URL },
|
|
43
|
+
app: Object.assign({}, app, { buildId: build_id }),
|
|
38
44
|
version,
|
|
39
45
|
git,
|
|
40
46
|
project: pluginOptions.app.project,
|
|
@@ -42,13 +48,14 @@ function getBuildStats({ stats, stats_json, pluginOptions, EDGE_URL, PLATFORM, }
|
|
|
42
48
|
remote: remote_name,
|
|
43
49
|
remotes: Object.keys(pluginOptions.mfConfig?.remotes || {}),
|
|
44
50
|
context: {
|
|
45
|
-
isCI: pluginOptions.isCI,
|
|
51
|
+
isCI: pluginOptions.zephyr_engine.env.isCI,
|
|
46
52
|
},
|
|
47
53
|
build_target: pluginOptions.target,
|
|
48
54
|
};
|
|
49
55
|
// todo: extend data
|
|
56
|
+
// @ts-expect-error incompatible types
|
|
50
57
|
const res = Object.assign({}, convertedGraph, data_overrides);
|
|
51
|
-
(0,
|
|
58
|
+
(0, zephyr_agent_1.ze_log)('get build stats done.', res);
|
|
52
59
|
return res;
|
|
53
60
|
}
|
|
54
61
|
exports.getBuildStats = getBuildStats;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-build-stats.js","sourceRoot":"","sources":["../../../src/lib/build-stats/get-build-stats.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,+
|
|
1
|
+
{"version":3,"file":"get-build-stats.js","sourceRoot":"","sources":["../../../src/lib/build-stats/get-build-stats.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,+DAA4D;AAE5D,6EAAkF;AAElF,+CAA6D;AAEtD,KAAK,UAAU,aAAa,CAAC,EAClC,KAAK,EACL,UAAU,EACV,aAAa,GACI;IACjB,IAAA,qBAAM,EAAC,gCAAgC,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,IAAI,6CAAyB,CAAC;QACpD,GAAG,EAAE,aAAa,CAAC,GAAG;QACtB,GAAG,EAAE,aAAa,CAAC,GAAG;QACtB,OAAO,EAAE;YACP,IAAI;SACL;QACD,MAAM,EAAE,aAAa,CAAC,MAAM;KAC7B,CAAC,CAAC;IAEH,IAAA,qBAAM,EAAC,0BAA0B,CAAC,CAAC;IACnC,MAAM,cA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;QAC3D,OAAO,EAAE;YACP,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI;SAC3C;QACD,YAAY,EAAE,aAAa,CAAC,MAAM;KACnC,CAAC;IAEF,oBAAoB;IACpB,sCAAsC;IACtC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,cAAc,CAAqB,CAAC;IAClF,IAAA,qBAAM,EAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC;AACb,CAAC;AA9DD,sCA8DC"}
|
|
@@ -3,24 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.replace_remote_with_delegates = void 0;
|
|
4
4
|
const zephyr_delegate_1 = require("../../delegate-module/zephyr-delegate");
|
|
5
5
|
const plugin_search_1 = require("../utils/plugin-search");
|
|
6
|
-
const
|
|
6
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
7
7
|
async function replace_remote_with_delegates(_config, { org, project, target }) {
|
|
8
|
-
(0,
|
|
9
|
-
(0,
|
|
8
|
+
(0, zephyr_agent_1.ze_log)('start replacing remote with delegate...');
|
|
9
|
+
(0, zephyr_agent_1.ze_log)('config plugins:', _config.plugins?.length);
|
|
10
10
|
// Set public path to auto to resolve the remote dependency prevent Repack from using their own public path, need to set this as soon as possible
|
|
11
11
|
// Reference: https://github.com/callstack/repack/blob/3b1f6021c199559989502f9ade978f2690e958ff/packages/repack/src/utils/getPublicPath.ts#L38
|
|
12
12
|
// TODO: this should only be done in a remote, not in the host
|
|
13
13
|
//_config.output!.publicPath = 'auto'
|
|
14
14
|
const mf_plugins = _config.plugins?.filter(plugin_search_1.is_module_federation_plugin) || [];
|
|
15
|
-
(0,
|
|
15
|
+
(0, zephyr_agent_1.ze_log)('found module federation plugins:', mf_plugins.length);
|
|
16
16
|
const dependency_resolution_tasks = mf_plugins.map((mfConfig) => {
|
|
17
|
-
(0,
|
|
18
|
-
(0,
|
|
17
|
+
(0, zephyr_agent_1.ze_log)('processing module federation config:', mfConfig);
|
|
18
|
+
(0, zephyr_agent_1.ze_log)('does mfConfig._options exist?', mfConfig?.config);
|
|
19
19
|
return (0, zephyr_delegate_1.replace_remote_in_mf_config)(mfConfig, { org, project, target });
|
|
20
20
|
});
|
|
21
21
|
if (dependency_resolution_tasks) {
|
|
22
22
|
const dependency_resolution_result = await Promise.all(dependency_resolution_tasks);
|
|
23
|
-
(0,
|
|
23
|
+
(0, zephyr_agent_1.ze_log)('dependency resolution completed successfully:', dependency_resolution_result);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.replace_remote_with_delegates = replace_remote_with_delegates;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-remote-with-delegates.js","sourceRoot":"","sources":["../../../src/lib/dependency-resolution/replace-remote-with-delegates.ts"],"names":[],"mappings":";;;AACA,2EAAoF;AACpF,0DAAqE;AAErE,+
|
|
1
|
+
{"version":3,"file":"replace-remote-with-delegates.js","sourceRoot":"","sources":["../../../src/lib/dependency-resolution/replace-remote-with-delegates.ts"],"names":[],"mappings":";;;AACA,2EAAoF;AACpF,0DAAqE;AAErE,+CAAsC;AAE/B,KAAK,UAAU,6BAA6B,CACjD,OAAsB,EACtB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAkB;IAExC,IAAA,qBAAM,EAAC,yCAAyC,CAAC,CAAC;IAClD,IAAA,qBAAM,EAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEnD,iJAAiJ;IACjJ,8IAA8I;IAC9I,8DAA8D;IAC9D,qCAAqC;IAErC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,2CAA2B,CAAC,IAAI,EAAE,CAAC;IAC9E,IAAA,qBAAM,EAAC,kCAAkC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE9D,MAAM,2BAA2B,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE;QACnE,IAAA,qBAAM,EAAC,sCAAsC,EAAE,QAAQ,CAAC,CAAC;QAEzD,IAAA,qBAAM,EAAC,+BAA+B,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,IAAA,6CAA2B,EAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,IAAI,2BAA2B,EAAE,CAAC;QAChC,MAAM,4BAA4B,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACpF,IAAA,qBAAM,EAAC,+CAA+C,EAAE,4BAA4B,CAAC,CAAC;IACxF,CAAC;AACH,CAAC;AA1BD,sEA0BC"}
|
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const find_package_json_1 = tslib_1.__importDefault(require("find-package-json"));
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
-
const
|
|
7
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
8
8
|
const ComputeSharedDependenciesFederation = ({ exclude, ignoreVersion, packageJson, ignorePatchVersion = true, shareFrom = ['dependencies'], }) => {
|
|
9
9
|
if (!packageJson) {
|
|
10
10
|
throw new Error('ComputeDependencyFederation: You must pass the package.json file of your app');
|
|
@@ -31,7 +31,7 @@ const ComputeSharedDependenciesFederation = ({ exclude, ignoreVersion, packageJs
|
|
|
31
31
|
packageVersion = require(packageJsonPath).version.split('.');
|
|
32
32
|
}
|
|
33
33
|
catch (e) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_SHARED_PACKAGE, {
|
|
35
35
|
cause: "We couldn't find Federation shared package's version - are you sure this is a valid package installed from npm registry?",
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ const ComputeSharedDependenciesFederation = ({ exclude, ignoreVersion, packageJs
|
|
|
41
41
|
const jsonValue = f.next().value;
|
|
42
42
|
const filePath = f.next().filename;
|
|
43
43
|
if (!filePath || typeof filePath !== 'string') {
|
|
44
|
-
(0,
|
|
44
|
+
(0, zephyr_agent_1.ze_log)("Package.json path not found - we couldn't find package.");
|
|
45
45
|
}
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
47
47
|
packageVersion = require(filePath).version.split('.');
|
|
@@ -49,8 +49,12 @@ const ComputeSharedDependenciesFederation = ({ exclude, ignoreVersion, packageJs
|
|
|
49
49
|
if (ignorePatchVersion && packageVersion) {
|
|
50
50
|
packageVersion.pop();
|
|
51
51
|
}
|
|
52
|
-
const versionedPkgName = packageVersion
|
|
53
|
-
|
|
52
|
+
const versionedPkgName = packageVersion
|
|
53
|
+
? `${pkg}-${packageVersion.join('.')}`
|
|
54
|
+
: pkg;
|
|
55
|
+
if (ignoreVersion &&
|
|
56
|
+
Array.isArray(ignoreVersion) &&
|
|
57
|
+
ignoreVersion.includes(pkg)) {
|
|
54
58
|
shared[pkg] = pkg;
|
|
55
59
|
}
|
|
56
60
|
else {
|
|
@@ -59,7 +63,7 @@ const ComputeSharedDependenciesFederation = ({ exclude, ignoreVersion, packageJs
|
|
|
59
63
|
}
|
|
60
64
|
catch (e) {
|
|
61
65
|
// Skip package if there's an error
|
|
62
|
-
(0,
|
|
66
|
+
(0, zephyr_agent_1.ze_log)(`Error during finding Federation required shared package: `, e, 'Skipping package to next...');
|
|
63
67
|
return shared;
|
|
64
68
|
}
|
|
65
69
|
return shared;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-dependencies.js","sourceRoot":"","sources":["../../../src/lib/federation-graph/compute-dependencies.ts"],"names":[],"mappings":";;;AAAA,kFAAqC;AACrC,mDAA6B;AAC7B,+CAAyB;
|
|
1
|
+
{"version":3,"file":"compute-dependencies.js","sourceRo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G,CAAC,EAC3B,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YACpB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAC;YACjC,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,mCAAmC;YACnC,IAAA,qBAAM,EACJ,2DAA2D,EAC3D,CAAC,EACD,6BAA6B,CAC9B,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,EAA4B,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,mCAAmC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-version.js","sourceRoot":"","sources":["../../../src/lib/federation-graph/compute-version.ts"],"names":[],"mappings":";;;AAAA,2DAA8C;AAG9C,IAAI,CAAC;IACH,cAAM,GAAG,IAAA,6BAAQ,EAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAEM,MAAM,sBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"compute-version.js","sourceRoot":"","sources":["../../../src/lib/federation-graph/compute-version.ts"],"names":[],"mappings":";;;AAAA,2DAA8C;AAG9C,IAAI,CAAC;IACH,cAAM,GAAG,IAAA,6BAAQ,EAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAEM,MAAM,sBAAsB,GAAG,CACpC,KAAwB,EACxB,GAAuB,EACH,EAAE;IACtB,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,QAAQ;YACX,OAAO,cAAM,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB;YACE,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,cAAM,CAAC;IACzC,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC"}
|
|
@@ -16,16 +16,19 @@ export declare class FederationDashboardPlugin {
|
|
|
16
16
|
constructor(options: Partial<FederationDashboardPluginOptions>);
|
|
17
17
|
/** @param {Compiler} compiler */
|
|
18
18
|
apply(compiler: Compiler): void;
|
|
19
|
-
processRspackGraph({ stats, stats_json, pluginOptions }: ProcessRspackGraphParams): ConvertedGraph | undefined;
|
|
19
|
+
processRspackGraph({ stats, stats_json, pluginOptions, }: ProcessRspackGraphParams): ConvertedGraph | undefined;
|
|
20
20
|
getRemoteEntryChunk(stats: StatsCompilation, FederationPluginOptions: typeof this.FederationPluginOptions): StatsChunk | undefined;
|
|
21
21
|
/**
|
|
22
22
|
* Return { "main": [{...dep1Details}, {...dep2Details}], "vendor": [{...dep3Details}],
|
|
23
23
|
*
|
|
24
|
-
* 1. Useful for dynamic imports - object generated could inform the bundler or runtime
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* 1. Useful for dynamic imports - object generated could inform the bundler or runtime
|
|
25
|
+
* loader about which chunks are needed for specific part of the app, enabling better
|
|
26
|
+
* performance optimization 1.1 if a chunk representing a React component dynamically
|
|
27
|
+
* loads, this dependency graph can help the runtime understand what other chunks
|
|
28
|
+
* need to be loaded alongside it.
|
|
29
|
+
* 2. Optimized loading and caching: By mapping chunk dependencies, this function supports
|
|
30
|
+
* advanced optimizations like caching. Chunks that haven’t changed between builds
|
|
31
|
+
* can be cached separately, reducing the need for users to download unchanged code.
|
|
29
32
|
*
|
|
30
33
|
* }
|
|
31
34
|
*/
|
|
@@ -33,14 +36,16 @@ export declare class FederationDashboardPlugin {
|
|
|
33
36
|
buildVendorFederationMap(liveStats: Stats): TopLevelPackage;
|
|
34
37
|
mapToObjectRec(m: Record<string, Chunk[keyof Chunk]> | Map<string, Chunk[keyof Chunk]> | Chunk[keyof Chunk][]): Record<string, unknown>;
|
|
35
38
|
/**
|
|
36
|
-
* In a remote application, this function is used to find all the chunks that are
|
|
37
|
-
* anything from HostApp
|
|
39
|
+
* In a remote application, this function is used to find all the chunks that are
|
|
40
|
+
* referenced by the remote entry chunk It won't return anything from HostApp
|
|
38
41
|
*/
|
|
39
42
|
buildValidChunkArray(liveStats: Stats, FederationPluginOptions: typeof this.FederationPluginOptions): Chunk[];
|
|
40
43
|
/**
|
|
41
|
-
* We are doing this because the filename in React Native is the actual JS bundle, "How
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
+
* We are doing this because the filename in React Native is the actual JS bundle, "How
|
|
45
|
+
* we understand the filename is different in react native" - filename would be at the
|
|
46
|
+
* end of the URL modified in get_mf_config.ts If we don't attach the remote bundle name
|
|
47
|
+
* to metadata, we will have no track record of the actual bundle when we need it later
|
|
48
|
+
* -- this is RePack specific.
|
|
44
49
|
*/
|
|
45
50
|
attach_remote_bundle_name_to_metadata(): Record<string, string> | undefined;
|
|
46
51
|
postDashboardData(dashData: any): Promise<{
|
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FederationDashboardPlugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
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
6
|
const compute_version_1 = require("./compute-version");
|
|
9
7
|
const runtime_requirement_1 = require("./runtime-requirement");
|
|
10
8
|
const plugin_search_1 = require("../utils/plugin-search");
|
|
11
9
|
const federation_plugin_get_package_json_1 = require("../utils/federation-plugin-get-package-json");
|
|
12
10
|
const compute_dependencies_1 = tslib_1.__importDefault(require("./compute-dependencies"));
|
|
13
11
|
const convert_to_graph_1 = require("./utils/convert-to-graph");
|
|
12
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
14
13
|
const remote_entry_last_part = 'mf-manifest.json';
|
|
15
14
|
class FederationDashboardPlugin {
|
|
16
15
|
constructor(options) {
|
|
@@ -38,15 +37,18 @@ class FederationDashboardPlugin {
|
|
|
38
37
|
throw new Error('Statistic plugin is missing Module Federation of standalone option');
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
processRspackGraph({ stats, stats_json, pluginOptions }) {
|
|
40
|
+
processRspackGraph({ stats, stats_json, pluginOptions, }) {
|
|
42
41
|
this.FederationPluginOptions = Object.assign({}, this.FederationPluginOptions, pluginOptions.mfConfig);
|
|
43
42
|
const RemoteEntryChunk = this.getRemoteEntryChunk(stats_json, this.FederationPluginOptions);
|
|
44
43
|
const validChunkArray = this.buildValidChunkArray(stats, this.FederationPluginOptions);
|
|
45
44
|
const chunkDependencies = this.getChunkDependencies(validChunkArray);
|
|
46
45
|
const vendorFederation = this.buildVendorFederationMap(stats);
|
|
47
46
|
// TODO: this type casting might not be every compilation result from rspack, but it's fine for now
|
|
48
|
-
const getPlatformFromStats = stats.compilation
|
|
49
|
-
|
|
47
|
+
const getPlatformFromStats = stats.compilation
|
|
48
|
+
.name;
|
|
49
|
+
const remotes = this.FederationPluginOptions?.remotes
|
|
50
|
+
? Object.keys(this.FederationPluginOptions.remotes)
|
|
51
|
+
: [];
|
|
50
52
|
const rawData = {
|
|
51
53
|
name: this.FederationPluginOptions?.name,
|
|
52
54
|
remotes: remotes,
|
|
@@ -67,8 +69,8 @@ class FederationDashboardPlugin {
|
|
|
67
69
|
};
|
|
68
70
|
let graphData;
|
|
69
71
|
try {
|
|
70
|
-
graphData = (0, convert_to_graph_1.convertToGraph)(rawData
|
|
71
|
-
(0,
|
|
72
|
+
graphData = (0, convert_to_graph_1.convertToGraph)(rawData);
|
|
73
|
+
(0, zephyr_agent_1.ze_log)('\n\n', 'graphData', graphData, '\n\n');
|
|
72
74
|
}
|
|
73
75
|
catch (err) {
|
|
74
76
|
console.warn('Error during dashboard data processing..');
|
|
@@ -89,11 +91,14 @@ class FederationDashboardPlugin {
|
|
|
89
91
|
/**
|
|
90
92
|
* Return { "main": [{...dep1Details}, {...dep2Details}], "vendor": [{...dep3Details}],
|
|
91
93
|
*
|
|
92
|
-
* 1. Useful for dynamic imports - object generated could inform the bundler or runtime
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
94
|
+
* 1. Useful for dynamic imports - object generated could inform the bundler or runtime
|
|
95
|
+
* loader about which chunks are needed for specific part of the app, enabling better
|
|
96
|
+
* performance optimization 1.1 if a chunk representing a React component dynamically
|
|
97
|
+
* loads, this dependency graph can help the runtime understand what other chunks
|
|
98
|
+
* need to be loaded alongside it.
|
|
99
|
+
* 2. Optimized loading and caching: By mapping chunk dependencies, this function supports
|
|
100
|
+
* advanced optimizations like caching. Chunks that haven’t changed between builds
|
|
101
|
+
* can be cached separately, reducing the need for users to download unchanged code.
|
|
97
102
|
*
|
|
98
103
|
* }
|
|
99
104
|
*/
|
|
@@ -127,7 +132,7 @@ class FederationDashboardPlugin {
|
|
|
127
132
|
packageJson = require(this._options.packageJsonPath);
|
|
128
133
|
}
|
|
129
134
|
catch (e) {
|
|
130
|
-
throw new
|
|
135
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_PACKAGE_JSON_NOT_FOUND, {
|
|
131
136
|
data: {
|
|
132
137
|
process: `While finding dependencies in package.json.`,
|
|
133
138
|
cause: e,
|
|
@@ -182,8 +187,8 @@ class FederationDashboardPlugin {
|
|
|
182
187
|
return lo;
|
|
183
188
|
}
|
|
184
189
|
/**
|
|
185
|
-
* In a remote application, this function is used to find all the chunks that are
|
|
186
|
-
* anything from HostApp
|
|
190
|
+
* In a remote application, this function is used to find all the chunks that are
|
|
191
|
+
* referenced by the remote entry chunk It won't return anything from HostApp
|
|
187
192
|
*/
|
|
188
193
|
buildValidChunkArray(liveStats, FederationPluginOptions) {
|
|
189
194
|
if (!FederationPluginOptions.name)
|
|
@@ -201,9 +206,11 @@ class FederationDashboardPlugin {
|
|
|
201
206
|
return validChunkArray;
|
|
202
207
|
}
|
|
203
208
|
/**
|
|
204
|
-
* We are doing this because the filename in React Native is the actual JS bundle, "How
|
|
205
|
-
*
|
|
206
|
-
*
|
|
209
|
+
* We are doing this because the filename in React Native is the actual JS bundle, "How
|
|
210
|
+
* we understand the filename is different in react native" - filename would be at the
|
|
211
|
+
* end of the URL modified in get_mf_config.ts If we don't attach the remote bundle name
|
|
212
|
+
* to metadata, we will have no track record of the actual bundle when we need it later
|
|
213
|
+
* -- this is RePack specific.
|
|
207
214
|
*/
|
|
208
215
|
attach_remote_bundle_name_to_metadata() {
|
|
209
216
|
if (!this.FederationPluginOptions.exposes) {
|
|
@@ -211,7 +218,7 @@ class FederationDashboardPlugin {
|
|
|
211
218
|
}
|
|
212
219
|
// TODO: not sure if this error would break the build. Silently log it for now
|
|
213
220
|
if (!this.FederationPluginOptions.bundle_name) {
|
|
214
|
-
console.warn(
|
|
221
|
+
console.warn(zephyr_agent_1.ZeErrors.ERR_MF_CONFIG_MISSING_FILENAME);
|
|
215
222
|
return;
|
|
216
223
|
}
|
|
217
224
|
return { remote_bundle_name: this.FederationPluginOptions.bundle_name };
|