uikit/scripts/build-bi-image-remote.mjs
Mohamadzadeh f9e1eb69a9
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 55s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
uikit-v1.8.2-biimage-demo-all-props-complete
2026-11-18 15:29:22 +03:30

21 lines
1.4 KiB
JavaScript

import { mkdir, readFile, writeFile } from "node:fs/promises";
// BiImage and AppHeader both depend on the same processImage utility.
// Rollup can otherwise move it to a shared chunk, leaving a downloadable
// BiImage.js with an extra network dependency. Keep this file self-contained
// while deriving the implementation DIRECTLY from the library utility source.
const remoteSource = await readFile("src/remote/ui/BiImage/BiImage.remote.js", "utf8");
const utilitySource = await readFile("src/utils/images.js", "utf8");
const styleSource = await readFile("src/remote/ui/BiImage/style-props.js", "utf8");
const styleImport = 'import { createImagePresentation, imagePresentationCSS } from "./style-props.js";';
const remoteImport = 'import { processImage } from "../../../utils/images.js";';
const utilityExport = "export const processImage =";
if (!remoteSource.includes(remoteImport) || !remoteSource.includes(styleImport) || !utilitySource.includes(utilityExport)) {
throw new Error("BiImage remote or processImage signature has changed; update the standalone remote builder.");
}
const remoteJs = remoteSource
.replace(remoteImport, utilitySource.replace(utilityExport, "const processImage =").trim())
.replace(styleImport, styleSource.replace(/export (const|function) /g, "$1 ").trim());
await mkdir("dist/remote", { recursive: true });
await writeFile("dist/remote/BiImage.js", remoteJs);