bimr-web/scripts/bundle-app.mjs
2026-08-31 10:49:15 +02:00

26 lines
1 KiB
JavaScript

// SPDX-FileCopyrightText: 2026 Milovann Yanatchkov
// SPDX-License-Identifier: MIT
// bundle-app.mjs — build the bimr-web viewer bundle via the esbuild JS API,
// using the cdn-to-bare plugin so three.js imports are bare specifiers that
// the import map in index.html resolves at runtime.
//
// Run from bimr-viewer-ifcx/src (where esbuild is installed), so the output
// matches the standalone bundle produced by the CLI build in the Makefile:
// cd ../bimr-viewer-ifcx/src && node ../../bimr-web/scripts/bundle-app.mjs
import { createRequire } from "node:module";
import { cdnToBare } from "../../bimr-web/scripts/cdn-to-bare.mjs";
const require = createRequire(process.cwd() + "/");
const esbuild = require("esbuild");
await esbuild.build({
entryPoints: ["viewer/render.ts"],
bundle: true,
// Bare-import bundle — Vite resolves three from node_modules at build
// time, so the app has no runtime CDN dependency (offline-capable).
outfile: "../../bimr-web/src/viewer.render.mjs",
format: "esm",
plugins: [cdnToBare],
});