// Bundle src/frost.ts (+ three@0.185.1 WebGPU/TSL, three-mesh-bvh) into one // classic IIFE at assets/frost.js exposing `window.Frost`. Run `npm install && npm run build` after editing src/. import "./tools/compile-preflight.mjs"; if (process.exitCode) process.exit(process.exitCode); // CPU-only shader generation checks the portable interface budget, including motion vectors. await import("./tools/run-shard-compile.mjs"); if (process.exitCode) process.exit(process.exitCode); import { build } from "esbuild"; import { createRequire } from "node:module"; import { statSync } from "node:fs"; const require = createRequire(import.meta.url); // The addons (SVGLoader, BufferGeometryUtils, GLTFLoader, three-mesh-bvh) import the classic `three` build; the // app uses `three/webgpu`, which re-exports the core. Point the bare specifier at the WebGPU build so exactly one // Three instance exists in the bundle (same alias as the experiment's vite.config.ts). const threeWebgpu = require.resolve("three/webgpu"); const threeAlias = { name: "three-webgpu-alias", setup(b) { b.onResolve({ filter: /^three$/ }, () => ({ path: threeWebgpu })); }, }; await build({ entryPoints: ["src/frost.ts"], bundle: true, format: "iife", globalName: "Frost", minify: true, sourcemap: false, target: ["es2022"], outfile: "assets/frost.js", plugins: [threeAlias], legalComments: "linked", logLevel: "info", banner: { js: "/* Frost: three@0.185.1 (MIT) + three-mesh-bvh@0.9.14 (MIT). Generated by build.mjs; edit src/ and rebuild. */", }, }); console.log(`assets/frost.js ${(statSync("assets/frost.js").size / 1024).toFixed(0)} KB`); // Lightweight workspace uses classic WebGL only; math/geometry helpers share their source // with the full WebGPU block without importing its renderer or simulation. await build({ entryPoints: ["src/motion/editor.ts"], bundle: true, format: "iife", minify: true, target: ["es2022"], outfile: "assets/motion.js", legalComments: "linked", logLevel: "info", plugins: [ { name: "motion-three", setup(b) { b.onResolve({ filter: /^three\/webgpu$/ }, () => ({ path: require.resolve("three").replace("three.cjs", "three.module.js"), })); }, }, ], });