// Loads TypeScript from lib/ with the app's own "@/" alias and no build step, // by way of Vite (already here for Vitest). Used by the eval scripts only. import { fileURLToPath } from "node:url"; import { createServer } from "vite"; const root = fileURLToPath(new URL("..", import.meta.url)); export async function load(paths) { const server = await createServer({ root, appType: "custom", logLevel: "silent", server: { middlewareMode: true, hmr: false, watch: null }, optimizeDeps: { noDiscovery: true, include: [] }, resolve: { alias: { "@": root.replace(/\/$/, "") } }, }); try { return await Promise.all(paths.map((p) => server.ssrLoadModule(p))); } finally { // The modules stay usable after the server closes; the process can exit. await server.close(); } }