zephyr-xpack-internal 0.0.58 → 0.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/federation-dashboard-legacy/get-build-stats.js +1 -0
- package/dist/federation-dashboard-legacy/get-build-stats.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/types/module-federation.types.d.ts +33 -0
- package/dist/types/module-federation.types.js +5 -0
- package/dist/types/module-federation.types.js.map +1 -0
- package/dist/xpack-extract/index.d.ts +1 -0
- package/dist/xpack-extract/index.js +3 -1
- package/dist/xpack-extract/index.js.map +1 -1
- package/dist/xpack-extract/is-legacy-mf-plugin.d.ts +2 -0
- package/dist/xpack-extract/is-legacy-mf-plugin.js +50 -0
- package/dist/xpack-extract/is-legacy-mf-plugin.js.map +1 -0
- package/dist/xpack-extract/iterate-federated-remote-config.d.ts +2 -2
- package/dist/xpack-extract/iterate-federated-remote-config.js +1 -1
- package/dist/xpack-extract/iterate-federated-remote-config.js.map +1 -1
- package/dist/xpack-extract/mut-webpack-federated-remotes-config.js +26 -6
- package/dist/xpack-extract/mut-webpack-federated-remotes-config.js.map +1 -1
- package/dist/xpack-extract/runtime-plugin-insert.d.ts +2 -0
- package/dist/xpack-extract/runtime-plugin-insert.js +36 -0
- package/dist/xpack-extract/runtime-plugin-insert.js.map +1 -0
- package/dist/xpack-extract/runtime-plugin.d.ts +8 -0
- package/dist/xpack-extract/runtime-plugin.js +117 -0
- package/dist/xpack-extract/runtime-plugin.js.map +1 -0
- package/dist/xpack.types.d.ts +8 -0
- package/package.json +3 -3
|
@@ -50,6 +50,7 @@ async function getBuildStats({ stats, stats_json, pluginOptions, EDGE_URL, DOMAI
|
|
|
50
50
|
remotes: remotes?.map(({ application_uid }) => application_uid) ?? [],
|
|
51
51
|
context: { isCI },
|
|
52
52
|
build_target,
|
|
53
|
+
zephyrDependencies: ze_engine.zephyr_dependencies,
|
|
53
54
|
};
|
|
54
55
|
// todo: extend data
|
|
55
56
|
const res = Object.assign({}, convertedGraph, data_overrides, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-build-stats.js","sourceRoot":"","sources":["../../src/federation-dashboard-legacy/get-build-stats.ts"],"names":[],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"get-build-stats.js","sourceRoot":"","sources":["../../src/federation-dashboard-legacy/get-build-stats.ts"],"names":[],"mappings":";;AAiBA,sCA8EC;AA9FD,+CAA6D;AAE7D,0FAAoF;AAEpF,6GAA0G;AAYnG,KAAK,UAAU,aAAa,CAA2C,EAC5E,KAAK,EACL,UAAU,EACV,aAAa,EACb,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,SAAS,EAAE,SAAS,GAAG,SAAS,GAOjC;IACC,qBAAM,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC;IAC9C,MAAM,GAAG,GAAG,SAAS,CAAC,qBAAqB,CAAC;IAC5C,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,aAAa,CAAC;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC;IAC/B,MAAM,eAAe,GAAG,IAAI,qDAAyB,CAAC;QACpD,GAAG;QACH,GAAG;QACH,OAAO,EAAE;YACP,IAAI;SACL;KACF,CAAC,CAAC;IAEH,qBAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,aAAa,CAAC,CAAC;IACjE,MAAM,cAAc,GAAG,eAAe,CAAC,mBAAmB,CAAC;QACzD,KAAK;QACL,UAAU;QACV,aAAa;KACd,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,0BAAW,CAAC,uBAAQ,CAAC,8BAA8B,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC;IAC3C,MAAM,eAAe,GAAG,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,EAAE,+BAA+B;QAC9C,IAAI,EAAE,EAAE,EAAE,wDAAwD;KACnE,CAAqB,CAAC;IACvB,qBAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Remote {
|
|
2
|
+
name: string;
|
|
3
|
+
alias?: string;
|
|
4
|
+
entry?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
shareScope?: string;
|
|
7
|
+
entryGlobalName?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Options {
|
|
10
|
+
name: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
remotes: Remote[];
|
|
13
|
+
shared: {
|
|
14
|
+
[pkgName: string]: any;
|
|
15
|
+
};
|
|
16
|
+
plugins?: FederationRuntimePlugin[];
|
|
17
|
+
shareStrategy?: 'version-first' | 'loaded-first';
|
|
18
|
+
}
|
|
19
|
+
export interface BeforeRequestHookArgs {
|
|
20
|
+
id: string;
|
|
21
|
+
options: Options;
|
|
22
|
+
origin: any;
|
|
23
|
+
}
|
|
24
|
+
export interface FederationRuntimePlugin {
|
|
25
|
+
name: string;
|
|
26
|
+
version?: string;
|
|
27
|
+
beforeRequest?: (args: BeforeRequestHookArgs) => BeforeRequestHookArgs | Promise<BeforeRequestHookArgs>;
|
|
28
|
+
}
|
|
29
|
+
export interface RemoteWithEntry {
|
|
30
|
+
name: string;
|
|
31
|
+
alias?: string;
|
|
32
|
+
entry: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-federation.types.js","sourceRoot":"","sources":["../../src/types/module-federation.types.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,kDAAkD"}
|
|
@@ -5,3 +5,4 @@ export { isModuleFederationPlugin } from './is-module-federation-plugin';
|
|
|
5
5
|
export { iterateFederationConfig } from './iterate-federation-config';
|
|
6
6
|
export { makeCopyOfModuleFederationOptions } from './make-copy-of-module-federation-options';
|
|
7
7
|
export { mutWebpackFederatedRemotesConfig } from './mut-webpack-federated-remotes-config';
|
|
8
|
+
export { createZephyrRuntimePlugin } from './runtime-plugin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mutWebpackFederatedRemotesConfig = exports.makeCopyOfModuleFederationOptions = exports.iterateFederationConfig = exports.isModuleFederationPlugin = exports.extractFederatedConfig = exports.parseRemotesAsEntries = exports.extractFederatedDependencyPairs = exports.xpack_delegate_module_template = exports.createMfRuntimeCode = void 0;
|
|
3
|
+
exports.createZephyrRuntimePlugin = exports.mutWebpackFederatedRemotesConfig = exports.makeCopyOfModuleFederationOptions = exports.iterateFederationConfig = exports.isModuleFederationPlugin = exports.extractFederatedConfig = exports.parseRemotesAsEntries = exports.extractFederatedDependencyPairs = exports.xpack_delegate_module_template = exports.createMfRuntimeCode = void 0;
|
|
4
4
|
var create_mf_runtime_code_1 = require("./create-mf-runtime-code");
|
|
5
5
|
Object.defineProperty(exports, "createMfRuntimeCode", { enumerable: true, get: function () { return create_mf_runtime_code_1.createMfRuntimeCode; } });
|
|
6
6
|
Object.defineProperty(exports, "xpack_delegate_module_template", { enumerable: true, get: function () { return create_mf_runtime_code_1.xpack_delegate_module_template; } });
|
|
@@ -17,4 +17,6 @@ var make_copy_of_module_federation_options_1 = require("./make-copy-of-module-fe
|
|
|
17
17
|
Object.defineProperty(exports, "makeCopyOfModuleFederationOptions", { enumerable: true, get: function () { return make_copy_of_module_federation_options_1.makeCopyOfModuleFederationOptions; } });
|
|
18
18
|
var mut_webpack_federated_remotes_config_1 = require("./mut-webpack-federated-remotes-config");
|
|
19
19
|
Object.defineProperty(exports, "mutWebpackFederatedRemotesConfig", { enumerable: true, get: function () { return mut_webpack_federated_remotes_config_1.mutWebpackFederatedRemotesConfig; } });
|
|
20
|
+
var runtime_plugin_1 = require("./runtime-plugin");
|
|
21
|
+
Object.defineProperty(exports, "createZephyrRuntimePlugin", { enumerable: true, get: function () { return runtime_plugin_1.createZephyrRuntimePlugin; } });
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xpack-extract/index.ts"],"names":[],"mappings":";;;AAAA,mEAGkC;AAFhC,6HAAA,mBAAmB,OAAA;AACnB,wIAAA,8BAA8B,OAAA;AAEhC,2FAG8C;AAF5C,qJAAA,+BAA+B,OAAA;AAC/B,2IAAA,qBAAqB,OAAA;AAEvB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,6EAAyE;AAAhE,uIAAA,wBAAwB,OAAA;AACjC,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,mGAA6F;AAApF,2JAAA,iCAAiC,OAAA;AAC1C,+FAA0F;AAAjF,wJAAA,gCAAgC,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xpack-extract/index.ts"],"names":[],"mappings":";;;AAAA,mEAGkC;AAFhC,6HAAA,mBAAmB,OAAA;AACnB,wIAAA,8BAA8B,OAAA;AAEhC,2FAG8C;AAF5C,qJAAA,+BAA+B,OAAA;AAC/B,2IAAA,qBAAqB,OAAA;AAEvB,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,6EAAyE;AAAhE,uIAAA,wBAAwB,OAAA;AACjC,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAChC,mGAA6F;AAApF,2JAAA,iCAAiC,OAAA;AAC1C,+FAA0F;AAAjF,wJAAA,gCAAgC,OAAA;AACzC,mDAA6D;AAApD,2HAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLegacyMFPlugin = isLegacyMFPlugin;
|
|
4
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
5
|
+
const extract_federation_config_1 = require("./extract-federation-config");
|
|
6
|
+
function isLegacyMFPlugin(plugin) {
|
|
7
|
+
const options = (0, extract_federation_config_1.extractFederatedConfig)(plugin);
|
|
8
|
+
if (!options) {
|
|
9
|
+
zephyr_agent_1.ze_log.mf('Not a Module Federation plugin');
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// If constructor name doesn't match, definitely not webpack's
|
|
13
|
+
if (plugin.constructor.name !== 'ModuleFederationPlugin') {
|
|
14
|
+
zephyr_agent_1.ze_log.mf('Non-legacy Module Federation plugin identified. Current plugin name: ', plugin.constructor.name);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const enhancedFeaturesChecks = [
|
|
18
|
+
// Core enhanced methods (likely present in most versions)
|
|
19
|
+
[plugin, 'getRemoteEntryUrls', 'function'],
|
|
20
|
+
[plugin, 'getContainerEntryModule', 'function'],
|
|
21
|
+
[plugin, 'invalidateRemote', 'function'],
|
|
22
|
+
// Newer enhanced methods (higher version requirements)
|
|
23
|
+
[plugin, 'statsResourceInfo'],
|
|
24
|
+
[plugin, 'getStats', 'function'],
|
|
25
|
+
// Configuration-based detection (version-agnostic)
|
|
26
|
+
[options, 'experiments'],
|
|
27
|
+
[options, 'runtimePlugins'],
|
|
28
|
+
[options, 'enhanced'],
|
|
29
|
+
// Internal properties (likely present across versions)
|
|
30
|
+
[plugin, '_experiments'],
|
|
31
|
+
[plugin, '_enhanced'],
|
|
32
|
+
];
|
|
33
|
+
for (const check of enhancedFeaturesChecks) {
|
|
34
|
+
if (hasProperty(...check)) {
|
|
35
|
+
zephyr_agent_1.ze_log.mf('Non-legacy Module Federation plugin identified. Plugin contains property: ', check[1]);
|
|
36
|
+
return false; // Has enhanced features, so NOT legacy
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// If we get here, it's webpack's native plugin
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const hasProperty = (target, property, type) => {
|
|
43
|
+
const hasProp = property in target;
|
|
44
|
+
if (!(property in target))
|
|
45
|
+
return false;
|
|
46
|
+
if (type)
|
|
47
|
+
return typeof target[property] === type;
|
|
48
|
+
return hasProp;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=is-legacy-mf-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-legacy-mf-plugin.js","sourceRoot":"","sources":["../../src/xpack-extract/is-legacy-mf-plugin.ts"],"names":[],"mappings":";;AAIA,4CA6CC;AAjDD,+CAAsC;AAEtC,2EAAqE;AAErE,SAAgB,gBAAgB,CAAC,MAA8B;IAC7D,MAAM,OAAO,GAAG,IAAA,kDAAsB,EAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,qBAAM,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8DAA8D;IAC9D,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACzD,qBAAM,CAAC,EAAE,CACP,uEAAuE,EACvE,MAAM,CAAC,WAAW,CAAC,IAAI,CACxB,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,sBAAsB,GAAa;QACvC,0DAA0D;QAC1D,CAAC,MAAM,EAAE,oBAAoB,EAAE,UAAU,CAAC;QAC1C,CAAC,MAAM,EAAE,yBAAyB,EAAE,UAAU,CAAC;QAC/C,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,CAAC;QACxC,uDAAuD;QACvD,CAAC,MAAM,EAAE,mBAAmB,CAAC;QAC7B,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;QAChC,mDAAmD;QACnD,CAAC,OAAO,EAAE,aAAa,CAAC;QACxB,CAAC,OAAO,EAAE,gBAAgB,CAAC;QAC3B,CAAC,OAAO,EAAE,UAAU,CAAC;QACrB,uDAAuD;QACvD,CAAC,MAAM,EAAE,cAAc,CAAC;QACxB,CAAC,MAAM,EAAE,WAAW,CAAC;KACtB,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,sBAAsB,EAAE,CAAC;QAC3C,IAAI,WAAW,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;YAC1B,qBAAM,CAAC,EAAE,CACP,4EAA4E,EAC5E,KAAK,CAAC,CAAC,CAAC,CACT,CAAC;YACF,OAAO,KAAK,CAAC,CAAC,uCAAuC;QACvD,CAAC;IACH,CAAC;IACD,+CAA+C;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC;AAID,MAAM,WAAW,GAAG,CAAC,MAAW,EAAE,QAAgB,EAAE,IAAa,EAAW,EAAE;IAC5E,MAAM,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC;IAEnC,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,IAAI,IAAI;QAAE,OAAO,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAElD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { XFederatedRemotesConfig, XPackConfiguration } from '../xpack.types';
|
|
2
|
-
export declare function iterateFederatedRemoteConfig<Compiler, K = XFederatedRemotesConfig>(config: XPackConfiguration<Compiler>, for_remote: (federatedRemoteConfig: XFederatedRemotesConfig) => K): K[];
|
|
1
|
+
import type { ModuleFederationPlugin, XFederatedRemotesConfig, XPackConfiguration } from '../xpack.types';
|
|
2
|
+
export declare function iterateFederatedRemoteConfig<Compiler, K = XFederatedRemotesConfig>(config: XPackConfiguration<Compiler>, for_remote: (federatedRemoteConfig: XFederatedRemotesConfig, plugin: ModuleFederationPlugin) => K): K[];
|
|
@@ -18,7 +18,7 @@ function iterateFederatedRemoteConfig(config, for_remote) {
|
|
|
18
18
|
(0, zephyr_agent_1.logFn)('warn', `No federated config found for plugin: ${plugin.constructor.name}, skipping...`);
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
|
-
results.push(for_remote(federatedConfig));
|
|
21
|
+
results.push(for_remote(federatedConfig, plugin));
|
|
22
22
|
}
|
|
23
23
|
zephyr_agent_1.ze_log.remotes('iterateFederatedRemoteConfig.results', results);
|
|
24
24
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate-federated-remote-config.js","sourceRoot":"","sources":["../../src/xpack-extract/iterate-federated-remote-config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"iterate-federated-remote-config.js","sourceRoot":"","sources":["../../src/xpack-extract/iterate-federated-remote-config.ts"],"names":[],"mappings":";;AASA,oEA+BC;AAxCD,+CAA6C;AAM7C,2EAAqE;AACrE,+EAAyE;AAEzE,SAAgB,4BAA4B,CAC1C,MAAoC,EACpC,UAGM;IAEN,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,IAAA,sDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QAED,MAAM,eAAe,GAAG,IAAA,kDAAsB,EAAC,MAAM,CAAC,CAAC;QAEvD,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAA,oBAAK,EACH,MAAM,EACN,yCAAyC,MAAM,CAAC,WAAW,CAAC,IAAI,eAAe,CAChF,CAAC;YACF,SAAS;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,qBAAM,CAAC,OAAO,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -5,18 +5,28 @@ const zephyr_agent_1 = require("zephyr-agent");
|
|
|
5
5
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
6
6
|
const extract_federated_dependency_pairs_1 = require("./extract-federated-dependency-pairs");
|
|
7
7
|
const index_1 = require("./index");
|
|
8
|
+
const is_legacy_mf_plugin_1 = require("./is-legacy-mf-plugin");
|
|
8
9
|
const iterate_federated_remote_config_1 = require("./iterate-federated-remote-config");
|
|
10
|
+
const runtime_plugin_insert_1 = require("./runtime-plugin-insert");
|
|
9
11
|
function mutWebpackFederatedRemotesConfig(zephyr_engine, config, resolvedDependencyPairs, delegate_module_template = index_1.xpack_delegate_module_template) {
|
|
10
12
|
if (!resolvedDependencyPairs?.length) {
|
|
11
13
|
zephyr_agent_1.ze_log.remotes(`No resolved dependency pairs found, skipping...`);
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
14
|
-
(
|
|
16
|
+
zephyr_agent_1.ze_log.remotes(`Processing ${resolvedDependencyPairs.length} resolved dependencies`);
|
|
17
|
+
(0, iterate_federated_remote_config_1.iterateFederatedRemoteConfig)(config, (remotesConfig, plugin) => {
|
|
15
18
|
const remotes = remotesConfig?.remotes;
|
|
16
19
|
if (!remotes) {
|
|
17
20
|
zephyr_agent_1.ze_log.remotes(`No remotes found for plugin: ${JSON.stringify(remotesConfig, null, 2)}`, 'skipping...');
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
23
|
+
let runtimePluginInserted = false;
|
|
24
|
+
const isRepack = zephyr_engine.builder === 'repack';
|
|
25
|
+
// Try runtime plugin insertion first if not legacy plugin and not Repack
|
|
26
|
+
if (!(0, is_legacy_mf_plugin_1.isLegacyMFPlugin)(plugin) && !isRepack) {
|
|
27
|
+
runtimePluginInserted = (0, runtime_plugin_insert_1.runtimePluginInsert)(plugin);
|
|
28
|
+
}
|
|
29
|
+
// Legacy processing - only if runtime plugin wasn't inserted or isEnhanced is false
|
|
20
30
|
const library_type = remotesConfig.library?.type ?? 'var';
|
|
21
31
|
zephyr_agent_1.ze_log.remotes(`Library type: ${library_type}`);
|
|
22
32
|
const remoteEntries = (0, extract_federated_dependency_pairs_1.parseRemotesAsEntries)(remotes);
|
|
@@ -32,27 +42,37 @@ function mutWebpackFederatedRemotesConfig(zephyr_engine, config, resolvedDepende
|
|
|
32
42
|
zephyr_agent_1.ze_log.remotes(`Resolved dependency pair not found for remote: ${JSON.stringify(remote, null, 2)}`, 'skipping...');
|
|
33
43
|
return;
|
|
34
44
|
}
|
|
45
|
+
const remote_entry_url = resolved_dep.remote_entry_url;
|
|
35
46
|
// todo: this is a version with named export logic, we should take this into account later
|
|
36
47
|
const [v_app] = remote_version.includes('@')
|
|
37
48
|
? remote_version.split('@')
|
|
38
49
|
: [remote_name];
|
|
39
50
|
zephyr_agent_1.ze_log.remotes(`v_app: ${v_app}`);
|
|
40
51
|
if (v_app) {
|
|
41
|
-
resolved_dep.remote_entry_url = [v_app,
|
|
42
|
-
zephyr_agent_1.ze_log.remotes(`Adding version to remote entry url: ${
|
|
52
|
+
resolved_dep.remote_entry_url = [v_app, remote_entry_url].join('@');
|
|
53
|
+
zephyr_agent_1.ze_log.remotes(`Adding version to remote entry url: ${remote_entry_url}`);
|
|
43
54
|
}
|
|
44
55
|
resolved_dep.library_type = library_type;
|
|
45
56
|
resolved_dep.name = (0, zephyr_edge_contract_1.normalize_app_name)(remote_name);
|
|
46
|
-
|
|
57
|
+
// Final value can be current one, zephyr delegate
|
|
58
|
+
// or fixed URL when using Zephyr Runtime plugin
|
|
59
|
+
let remote_final_value = resolved_dep.remote_entry_url;
|
|
60
|
+
if (!runtimePluginInserted && !isRepack) {
|
|
61
|
+
remote_final_value = (0, index_1.createMfRuntimeCode)(zephyr_engine, resolved_dep, delegate_module_template);
|
|
62
|
+
}
|
|
63
|
+
// Nx remote definition is an Array
|
|
47
64
|
if (Array.isArray(remotes)) {
|
|
48
65
|
const remoteIndex = remotes.indexOf(remote_name);
|
|
49
66
|
if (remoteIndex === -1)
|
|
50
67
|
return;
|
|
68
|
+
const nx_remote_value = remote_final_value.startsWith('promise')
|
|
69
|
+
? remote_final_value
|
|
70
|
+
: remote_entry_url; // Only the URL without alias for Nx definition
|
|
51
71
|
// @ts-expect-error - Nx's ModuleFederationPlugin has different remote types
|
|
52
|
-
remotes.splice(remoteIndex, 1, [remote_name,
|
|
72
|
+
remotes.splice(remoteIndex, 1, [remote_name, nx_remote_value]);
|
|
53
73
|
return;
|
|
54
74
|
}
|
|
55
|
-
remotes[remote_name] =
|
|
75
|
+
remotes[remote_name] = remote_final_value;
|
|
56
76
|
});
|
|
57
77
|
zephyr_agent_1.ze_log.remotes(`Set runtime code for remotes: ${remotes}`);
|
|
58
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mut-webpack-federated-remotes-config.js","sourceRoot":"","sources":["../../src/xpack-extract/mut-webpack-federated-remotes-config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mut-webpack-federated-remotes-config.js","sourceRoot":"","sources":["../../src/xpack-extract/mut-webpack-federated-remotes-config.ts"],"names":[],"mappings":";;AAUA,4EAuGC;AAhHD,+CAAiE;AACjE,+DAA0D;AAE1D,6FAA6E;AAC7E,mCAA8E;AAC9E,+DAAyD;AACzD,uFAAiF;AACjF,mEAA8D;AAE9D,SAAgB,gCAAgC,CAC9C,aAA2B,EAC3B,MAAoC,EACpC,uBAAsD,EACtD,2BAAsD,sCAA8B;IAEpF,IAAI,CAAC,uBAAuB,EAAE,MAAM,EAAE,CAAC;QACrC,qBAAM,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAC;QAClE,OAAO;IACT,CAAC;IAED,qBAAM,CAAC,OAAO,CAAC,cAAc,uBAAuB,CAAC,MAAM,wBAAwB,CAAC,CAAC;IAErF,IAAA,8DAA4B,EAAC,MAAM,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG,aAA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AC/B,MAAM,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,SAAS,CAAC;oBAC9D,CAAC,CAAC,kBAAkB;oBACpB,CAAC,CAAC,gBAAgB,CAAC,CAAC,+CAA+C;gBACrE,4EAA4E;gBAC5E,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC;gBAC/D,OAAO;YACT,CAAC;YAED,OAAO,CAAC,WAAW,CAAC,GAAG,kBAAkB,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,qBAAM,CAAC,OAAO,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runtimePluginInsert = runtimePluginInsert;
|
|
4
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
5
|
+
const extract_federation_config_1 = require("./extract-federation-config");
|
|
6
|
+
function runtimePluginInsert(plugin) {
|
|
7
|
+
try {
|
|
8
|
+
const runtimePluginPath = require.resolve('./runtime-plugin');
|
|
9
|
+
zephyr_agent_1.ze_log.remotes(`Adding Zephyr runtime plugin: ${runtimePluginPath}`);
|
|
10
|
+
let configRef = (0, extract_federation_config_1.extractFederatedConfig)(plugin);
|
|
11
|
+
if (!configRef) {
|
|
12
|
+
zephyr_agent_1.ze_log.remotes('No MF config found.');
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// handle NxModuleFederationPlugin wrapper
|
|
16
|
+
if ('configOverride' in plugin) {
|
|
17
|
+
plugin.configOverride ?? (plugin.configOverride = {});
|
|
18
|
+
configRef = plugin.configOverride;
|
|
19
|
+
}
|
|
20
|
+
// Initialize runtimePlugins array if it doesn't exist
|
|
21
|
+
if (!configRef.runtimePlugins) {
|
|
22
|
+
configRef.runtimePlugins = [];
|
|
23
|
+
}
|
|
24
|
+
// Add the runtime plugin only if it's not already present
|
|
25
|
+
if (!configRef.runtimePlugins.includes(runtimePluginPath)) {
|
|
26
|
+
configRef.runtimePlugins.push(runtimePluginPath);
|
|
27
|
+
}
|
|
28
|
+
zephyr_agent_1.ze_log.remotes(`Runtime plugin added to Module Federation config`);
|
|
29
|
+
return true; // Successfully inserted runtime plugin
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
zephyr_agent_1.ze_log.remotes(`Failed to resolve runtime plugin path: ${error}`);
|
|
33
|
+
return false; // Failed to insert runtime plugin
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=runtime-plugin-insert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-plugin-insert.js","sourceRoot":"","sources":["../../src/xpack-extract/runtime-plugin-insert.ts"],"names":[],"mappings":";;AAIA,kDAmCC;AAvCD,+CAAsC;AAEtC,2EAAqE;AAErE,SAAgB,mBAAmB,CAAC,MAA8B;IAChE,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC9D,qBAAM,CAAC,OAAO,CAAC,iCAAiC,iBAAiB,EAAE,CAAC,CAAC;QAErE,IAAI,SAAS,GACX,IAAA,kDAAsB,EAAC,MAAM,CAAC,CAAC;QAEjC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,qBAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,0CAA0C;QAC1C,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAAC;YAC/B,MAAM,CAAC,cAAc,KAArB,MAAM,CAAC,cAAc,GAAK,EAAE,EAAC;YAC7B,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;QACpC,CAAC;QAED,sDAAsD;QACtD,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;YAC9B,SAAS,CAAC,cAAc,GAAG,EAAE,CAAC;QAChC,CAAC;QAED,0DAA0D;QAC1D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC1D,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACnD,CAAC;QACD,qBAAM,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC;QAEnE,OAAO,IAAI,CAAC,CAAC,uCAAuC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qBAAM,CAAC,OAAO,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;QAClE,OAAO,KAAK,CAAC,CAAC,kCAAkC;IAClD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FederationRuntimePlugin } from '../types/module-federation.types';
|
|
2
|
+
/**
|
|
3
|
+
* Zephyr Runtime Plugin for Module Federation This plugin handles dynamic remote URL
|
|
4
|
+
* resolution at runtime using beforeRequest hook to mutate URLs on the fly
|
|
5
|
+
*/
|
|
6
|
+
export declare function createZephyrRuntimePlugin(): FederationRuntimePlugin;
|
|
7
|
+
/** Default export for use with Module Federation runtime plugins array */
|
|
8
|
+
export default createZephyrRuntimePlugin;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createZephyrRuntimePlugin = createZephyrRuntimePlugin;
|
|
4
|
+
// Ensure only one fetch is done by the app
|
|
5
|
+
const globalKey = '__ZEPHYR_MANIFEST_PROMISE__';
|
|
6
|
+
const _global = typeof window !== 'undefined' ? window : globalThis;
|
|
7
|
+
function getGlobalManifestPromise() {
|
|
8
|
+
return _global[globalKey];
|
|
9
|
+
}
|
|
10
|
+
function setGlobalManifestPromise(promise) {
|
|
11
|
+
_global[globalKey] = promise;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Zephyr Runtime Plugin for Module Federation This plugin handles dynamic remote URL
|
|
15
|
+
* resolution at runtime using beforeRequest hook to mutate URLs on the fly
|
|
16
|
+
*/
|
|
17
|
+
function createZephyrRuntimePlugin() {
|
|
18
|
+
let processedRemotes;
|
|
19
|
+
// Start fetching manifest immediately
|
|
20
|
+
let zephyrManifestPromise = getGlobalManifestPromise();
|
|
21
|
+
if (!zephyrManifestPromise) {
|
|
22
|
+
zephyrManifestPromise = fetchZephyrManifest();
|
|
23
|
+
setGlobalManifestPromise(zephyrManifestPromise);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
name: 'zephyr-runtime-remote-resolver',
|
|
27
|
+
async beforeRequest(args) {
|
|
28
|
+
const zephyrManifest = await zephyrManifestPromise;
|
|
29
|
+
if (!processedRemotes) {
|
|
30
|
+
processedRemotes = identifyRemotes(args, zephyrManifest);
|
|
31
|
+
}
|
|
32
|
+
// Extract remote name from args.id (format: "remoteName/componentName")
|
|
33
|
+
const remoteName = args.id.split('/')[0];
|
|
34
|
+
if (!processedRemotes[remoteName]) {
|
|
35
|
+
return args; // No matching remote found
|
|
36
|
+
}
|
|
37
|
+
// Get the resolved URL, checking session storage first
|
|
38
|
+
const resolvedUrl = getResolvedRemoteUrl(processedRemotes[remoteName]);
|
|
39
|
+
const targetRemote = args.options.remotes.find((remote) => hasEntry(remote) && (remote.name === remoteName || remote.alias === remoteName));
|
|
40
|
+
if (!targetRemote) {
|
|
41
|
+
return args;
|
|
42
|
+
}
|
|
43
|
+
// Update the remote entry URL
|
|
44
|
+
targetRemote.entry = resolvedUrl;
|
|
45
|
+
return args;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Fetches the zephyr-manifest.json file and returns the runtime plugin data */
|
|
50
|
+
async function fetchZephyrManifest() {
|
|
51
|
+
try {
|
|
52
|
+
// Fetch the manifest from the same origin
|
|
53
|
+
const response = await fetch('/zephyr-manifest.json');
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const manifest = await response.json().catch(() => undefined);
|
|
58
|
+
if (!manifest) {
|
|
59
|
+
console.error('Failed to parse manifest JSON');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
return manifest;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
console.error('Unexpected error fetching manifest');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function identifyRemotes(args, zephyrManifest) {
|
|
70
|
+
const identifiedRemotes = {};
|
|
71
|
+
// No runtime plugin configured
|
|
72
|
+
if (!zephyrManifest) {
|
|
73
|
+
return identifiedRemotes;
|
|
74
|
+
}
|
|
75
|
+
// No remotes defined
|
|
76
|
+
if (!args.options.remotes.length) {
|
|
77
|
+
return identifiedRemotes;
|
|
78
|
+
}
|
|
79
|
+
const { dependencies } = zephyrManifest;
|
|
80
|
+
const remotes = args.options.remotes;
|
|
81
|
+
remotes.forEach((remote) => {
|
|
82
|
+
const resolvedRemote = dependencies[remote.name] ?? dependencies[remote.alias ?? ''];
|
|
83
|
+
if (resolvedRemote) {
|
|
84
|
+
// Map both the original remote name and alias to the resolved remote
|
|
85
|
+
// Nx replaces aliases calls with the normalized name
|
|
86
|
+
identifiedRemotes[remote.name] = resolvedRemote;
|
|
87
|
+
if (remote.alias && remote.alias !== remote.name) {
|
|
88
|
+
identifiedRemotes[remote.alias] = resolvedRemote;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return identifiedRemotes;
|
|
93
|
+
}
|
|
94
|
+
function hasEntry(remote) {
|
|
95
|
+
return (remote !== null &&
|
|
96
|
+
remote !== undefined &&
|
|
97
|
+
typeof remote === 'object' &&
|
|
98
|
+
'entry' in remote &&
|
|
99
|
+
typeof remote.entry === 'string');
|
|
100
|
+
}
|
|
101
|
+
/** Resolves the actual remote URL, checking session storage for overrides */
|
|
102
|
+
function getResolvedRemoteUrl(resolvedRemote) {
|
|
103
|
+
const _window = typeof window !== 'undefined' ? window : globalThis;
|
|
104
|
+
// Check for session storage override (for development/testing)
|
|
105
|
+
const sessionEdgeURL = _window.sessionStorage?.getItem(resolvedRemote.application_uid);
|
|
106
|
+
// Use session URL if available, otherwise use resolved URL
|
|
107
|
+
let edgeUrl = sessionEdgeURL ?? resolvedRemote.remote_entry_url;
|
|
108
|
+
// Handle versioned remotes (name@url format)
|
|
109
|
+
if (edgeUrl.indexOf('@') !== -1) {
|
|
110
|
+
const [, url] = edgeUrl.split('@');
|
|
111
|
+
edgeUrl = url;
|
|
112
|
+
}
|
|
113
|
+
return edgeUrl;
|
|
114
|
+
}
|
|
115
|
+
/** Default export for use with Module Federation runtime plugins array */
|
|
116
|
+
exports.default = createZephyrRuntimePlugin;
|
|
117
|
+
//# sourceMappingURL=runtime-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-plugin.js","sourceRoot":"","sources":["../../src/xpack-extract/runtime-plugin.ts"],"names":[],"mappings":";;AAuBA,8DA6CC;AA7DD,2CAA2C;AAC3C,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;AAEpE,SAAS,wBAAwB;IAC/B,OAAQ,OAAe,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,wBAAwB,CAAC,OAA4C;IAC3E,OAAe,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,SAAgB,yBAAyB;IACvC,IAAI,gBAA8D,CAAC;IAEnE,sCAAsC;IACtC,IAAI,qBAAqB,GAAG,wBAAwB,EAAE,CAAC;IAEvD,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,mBAAmB,EAAE,CAAC;QAC9C,wBAAwB,CAAC,qBA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,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,QAAQ,CAAC,MAAW;IAC3B,OAAO,CACL,MAAM,KAAK,IAAI;QACf,MAAM,KAAK,SAAS;QACpB,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,IAAI,MAAM;QACjB,OAAQ,MAAc,CAAC,KAAK,KAAK,QAAQ,CAC1C,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,oBAAoB,CAAC,cAAgC;IAC5D,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;IAEpE,+DAA+D;IAC/D,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAEvF,2DAA2D;IAC3D,IAAI,OAAO,GAAG,cAAc,IAAI,cAAc,CAAC,gBAAgB,CAAC;IAEhE,6CAA6C;IAC7C,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;QACvD,OAAO,GAAG,GAAG,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,kBAAe,yBAAyB,CAAC"}
|
package/dist/xpack.types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface XFederatedRemotesConfig {
|
|
|
23
23
|
* actual output js.bundle and they want to put it in filename field)
|
|
24
24
|
*/
|
|
25
25
|
bundle_name?: string;
|
|
26
|
+
/** Runtime plugins for Module Federation */
|
|
27
|
+
runtimePlugins?: string[];
|
|
26
28
|
}
|
|
27
29
|
export interface ModuleFederationPlugin {
|
|
28
30
|
apply: (compiler: unknown) => void;
|
|
@@ -30,8 +32,14 @@ export interface ModuleFederationPlugin {
|
|
|
30
32
|
_options?: XFederatedRemotesConfig | {
|
|
31
33
|
config: XFederatedRemotesConfig;
|
|
32
34
|
};
|
|
35
|
+
/** For Nx Module Federation plugin */
|
|
36
|
+
options?: XFederatedRemotesConfig | {
|
|
37
|
+
config: XFederatedRemotesConfig;
|
|
38
|
+
};
|
|
33
39
|
/** Repack specific for now until Repack change how the config should be exposed */
|
|
34
40
|
config?: XFederatedRemotesConfig;
|
|
41
|
+
/** NxModuleFederationPlugin */
|
|
42
|
+
configOverride?: Omit<XFederatedRemotesConfig, 'exposes' | 'remotes' | 'name' | 'shared' | 'filename'>;
|
|
35
43
|
}
|
|
36
44
|
interface RemotesObject {
|
|
37
45
|
[index: string]: string | RemotesConfig | string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zephyr-xpack-internal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-next.1",
|
|
4
4
|
"description": "Xpack internals for Zephyr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@module-federation/automatic-vendor-federation": "^1.2.1",
|
|
20
20
|
"is-ci": "^4.1.0",
|
|
21
21
|
"tslib": "^2.8.1",
|
|
22
|
-
"zephyr-agent": "0.0.
|
|
23
|
-
"zephyr-edge-contract": "0.0.
|
|
22
|
+
"zephyr-agent": "0.1.0-next.1",
|
|
23
|
+
"zephyr-edge-contract": "0.1.0-next.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/is-ci": "3.0.4",
|