UNPKG

@gez/core

Version:

A high-performance microfrontend framework supporting Vue, React, Preact, Solid, and Svelte with SSR and Module Federation capabilities.

33 lines (32 loc) 960 B
import path from "node:path"; import { pathWithoutIndex } from "./path-without-index.mjs"; export async function getImportMap(target, manifests, moduleConfig) { const imports = {}; if (target === "client") { for (const manifest of manifests) { for (const [name, value] of Object.entries(manifest.exports)) { imports[`${manifest.name}/${name}`] = `/${manifest.name}/${value}`; } } } else { for (const manifest of manifests) { const link = moduleConfig.links.find( (item) => item.name === manifest.name ); if (!link) { throw new Error( `'${manifest.name}' service did not find module config` ); } for (const [name, value] of Object.entries(manifest.exports)) { imports[`${manifest.name}/${name}`] = path.resolve( link.root, "server", value ); } } } pathWithoutIndex(imports); return { imports }; }