uikit/scripts/build-bi-image-remote.mjs
Mohamadzadeh 96a434129a
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 1m1s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
uikit-v1.3.0-vite-swr-biimage
2026-10-27 13:55:26 +03:30

17 lines
1.1 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 remoteImport = 'import { processImage } from "../../../utils/images.js";';
const utilityExport = "export const processImage =";
if (!remoteSource.includes(remoteImport) || !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());
await mkdir("dist/remote", { recursive: true });
await writeFile("dist/remote/BiImage.js", remoteJs);