vite-plugin-zephyr 0.0.0-canary-20250214201112 → 0.0.0-canary-20250215130130
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/lib/internal/runtime/runtime-plugin.js +22 -0
- package/dist/lib/internal/types/zephyr-runtime.d.ts +4 -0
- package/dist/lib/internal/types/zephyr-runtime.js +3 -0
- package/dist/lib/internal/types/zephyr-runtime.js.map +1 -0
- package/dist/lib/vite-plugin-zephyr.js +29 -6
- package/dist/lib/vite-plugin-zephyr.js.map +1 -1
- package/package.json +2 -2
@@ -0,0 +1,22 @@
|
|
1
|
+
/** @type {() => import('@module-federation/runtime').FederationRuntimePlugin} */
|
2
|
+
const runtimePlugin = () => {
|
3
|
+
return {
|
4
|
+
name: 'ZephyrMFRuntimePlugin',
|
5
|
+
beforeRegisterRemote: (config) => {
|
6
|
+
console.log('------- remote before: ', JSON.stringify(config.remote, null, 2));
|
7
|
+
if (!window) return config;
|
8
|
+
const resolvedRemote = window.__ZEPHYR_GLOBAL__?.remoteMap?.[config.remote.name];
|
9
|
+
if (!resolvedRemote) return config;
|
10
|
+
|
11
|
+
const sessionEdgeURL = window.sessionStorage.getItem(
|
12
|
+
resolvedRemote.application_uid
|
13
|
+
);
|
14
|
+
if (!sessionEdgeURL) return config;
|
15
|
+
config.remote.entry = sessionEdgeURL;
|
16
|
+
console.log('------- remote after: ', JSON.stringify(config.remote, null, 2));
|
17
|
+
return config;
|
18
|
+
},
|
19
|
+
};
|
20
|
+
};
|
21
|
+
|
22
|
+
export default runtimePlugin;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"zephyr-runtime.js","sourceRoot":"","sources":["../../../../src/lib/internal/types/zephyr-runtime.ts"],"names":[],"mappings":""}
|
@@ -1,15 +1,25 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.withZephyr = withZephyr;
|
4
|
+
const tslib_1 = require("tslib");
|
4
5
|
const zephyr_agent_1 = require("zephyr-agent");
|
5
6
|
const vite_1 = require("@module-federation/vite");
|
6
7
|
const extract_vite_assets_map_1 = require("./internal/extract/extract_vite_assets_map");
|
7
8
|
const extract_mf_vite_remotes_1 = require("./internal/mf-vite-etl/extract-mf-vite-remotes");
|
8
9
|
const load_resolved_remotes_1 = require("./internal/mf-vite-etl/load_resolved_remotes");
|
10
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
9
11
|
function withZephyr(_options) {
|
10
12
|
const mfConfig = _options === null || _options === void 0 ? void 0 : _options.mfConfig;
|
11
13
|
const plugins = [];
|
12
14
|
if (mfConfig) {
|
15
|
+
const runtimePlugin = require.resolve(node_path_1.default.join(__dirname, './internal/runtime/runtime-plugin'));
|
16
|
+
console.log('---------- runtimePlugin: ', runtimePlugin);
|
17
|
+
if (Array.isArray(mfConfig.runtimePlugins)) {
|
18
|
+
mfConfig.runtimePlugins.push(runtimePlugin);
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
mfConfig.runtimePlugins = [runtimePlugin];
|
22
|
+
}
|
13
23
|
plugins.push(...(0, vite_1.federation)(mfConfig));
|
14
24
|
}
|
15
25
|
plugins.push(zephyrPlugin(_options));
|
@@ -17,10 +27,8 @@ function withZephyr(_options) {
|
|
17
27
|
}
|
18
28
|
function zephyrPlugin(_options) {
|
19
29
|
const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
|
20
|
-
|
21
|
-
const
|
22
|
-
resolve_vite_internal_options = resolve;
|
23
|
-
});
|
30
|
+
const vite_internal_options_defer = defer();
|
31
|
+
const remotes_defer = defer();
|
24
32
|
let root;
|
25
33
|
return {
|
26
34
|
name: 'with-zephyr',
|
@@ -32,7 +40,7 @@ function zephyrPlugin(_options) {
|
|
32
40
|
builder: 'vite',
|
33
41
|
context: config.root,
|
34
42
|
});
|
35
|
-
|
43
|
+
vite_internal_options_defer.resolve({
|
36
44
|
root: config.root,
|
37
45
|
outDir: (_a = config.build) === null || _a === void 0 ? void 0 : _a.outDir,
|
38
46
|
publicDir: config.publicDir,
|
@@ -46,10 +54,20 @@ function zephyrPlugin(_options) {
|
|
46
54
|
const resolved_remotes = await zephyr_engine.resolve_remote_dependencies(dependencyPairs);
|
47
55
|
if (!resolved_remotes)
|
48
56
|
return code;
|
57
|
+
remotes_defer.resolve(resolved_remotes);
|
49
58
|
return (0, load_resolved_remotes_1.load_resolved_remotes)(resolved_remotes, code, id);
|
50
59
|
},
|
60
|
+
transformIndexHtml: async (html) => {
|
61
|
+
const remotes = await remotes_defer.promise;
|
62
|
+
if (!(remotes === null || remotes === void 0 ? void 0 : remotes.length))
|
63
|
+
return;
|
64
|
+
const zephyrGlobal = {
|
65
|
+
remoteMap: Object.fromEntries(remotes.map((remote) => [remote.name, remote])),
|
66
|
+
};
|
67
|
+
return html.replace('</body>', `<script>window.__ZEPHYR_GLOBAL__ = ${JSON.stringify(zephyrGlobal)};</script></body>`);
|
68
|
+
},
|
51
69
|
closeBundle: async () => {
|
52
|
-
const vite_internal_options = await vite_internal_options_defer;
|
70
|
+
const vite_internal_options = await vite_internal_options_defer.promise;
|
53
71
|
const zephyr_engine = await zephyr_engine_defer;
|
54
72
|
await zephyr_engine.start_new_build();
|
55
73
|
const assetsMap = await (0, extract_vite_assets_map_1.extract_vite_assets_map)(zephyr_engine, vite_internal_options);
|
@@ -63,4 +81,9 @@ function zephyrPlugin(_options) {
|
|
63
81
|
},
|
64
82
|
};
|
65
83
|
}
|
84
|
+
function defer() {
|
85
|
+
let resolve;
|
86
|
+
const promise = new Promise((r) => (resolve = r));
|
87
|
+
return { promise, resolve };
|
88
|
+
}
|
66
89
|
//# sourceMappingURL=vite-plugin-zephyr.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"vite-plugin-zephy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AAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;aAC9E,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CACjB,SAAS,EACT,sCAAsC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,mBAAmB,CACtF,CAAC;QACJ,CAAC;QACD,WAAW,EAAE,KAAK,IAAI,EAAE;YACtB,MAAM,qBAAqB,GAAG,MAAM,2BAA2B,CAAC,OAAO,CAAC;YACxE,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC;YAEhD,MAAM,aAAa,CAAC,eAAe,EAAE,CAAC;YACtC,MAAM,SAAS,GAAG,MAAM,IAAA,iDAAuB,EAC7C,aAAa,EACb,qBAAqB,CACtB,CAAC;YAEF,MAAM,QAAQ,GAAa,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAoB,CAAC;YAC1D,MAAM,aAAa,CAAC,aAAa,CAAC;gBAChC,QAAQ;gBACR,SAAS;gBACT,UAAU,EAAE,MAAM,IAAA,8BAAe,EAAC,aAAa,EAAE,QAAQ,CAAC;aAC3D,CAAC,CAAC;YACH,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,KAAK;IACZ,IAAI,OAA4B,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vite-plugin-zephyr",
|
3
|
-
"version": "0.0.0-canary-
|
3
|
+
"version": "0.0.0-canary-20250215130130",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"json5": "2.2.3",
|
14
14
|
"rollup": "^4.22.5",
|
15
15
|
"vite": "^5.4.8",
|
16
|
-
"zephyr-agent": "0.0.0-canary-
|
16
|
+
"zephyr-agent": "0.0.0-canary-20250215130130"
|
17
17
|
},
|
18
18
|
"devDependencies": {
|
19
19
|
"@types/is-ci": "^3.0.4"
|