everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
34 lines (32 loc) • 1.57 kB
JavaScript
let every_plugin_ui_manifest = require("every-plugin/ui/manifest");
//#region src/ui/remote-entry.ts
const trimBase = (value) => (value ?? "").replace(/\/$/, "");
const withBuster = (url, buster) => buster ? `${url}?v=${encodeURIComponent(buster)}` : url;
function requireEntry(entryUrl, env, remote, surface, devFixed) {
if (entryUrl) return entryUrl;
if (env === "development") return devFixed;
throw new Error(`remote "${remote}" has no derived ${surface} entry — pins resolve it from the version manifest (the fixed dev name is development-only)`);
}
function ssrEntryUrl(remote, env) {
if (remote.ssrEntryUrl) return remote.ssrEntryUrl;
if (env === "development") return remote.ssrUrl ? withBuster(`${trimBase(remote.ssrUrl)}/${every_plugin_ui_manifest.UI_REMOTE_SERVER_ENTRY_FILENAME}`, remote.ssrIntegrity ?? remote.containerVersion) : void 0;
if (!remote.ssrUrl) return void 0;
throw new Error(`remote "${remote.name}" has no derived ssr entry — pins resolve it from the version manifest (the fixed dev name is development-only)`);
}
function entryUrls(remote, env) {
const base = trimBase(remote.publicUrl ?? remote.url);
return {
get ui() {
return requireEntry(remote.entryUrl, env, remote.name, "ui", withBuster(`${base}/${every_plugin_ui_manifest.UI_REMOTE_ENTRY_FILENAME}`, remote.integrity));
},
get ssr() {
return ssrEntryUrl(remote, env);
},
get browserManifest() {
return remote.localPath ? void 0 : remote.browserManifestUrl;
}
};
}
//#endregion
exports.entryUrls = entryUrls;
//# sourceMappingURL=remote-entry.cjs.map