Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import { build } from "esbuild";import { copyFileSync, mkdirSync, rmSync } from "node:fs";import { createRequire } from "node:module";
// slopbox's own bundles: the terminal pane (xterm + its fit addon) and the Shell tab's// bash interpreter (bashkit). Both used to live in @nibling/kernel's build; they moved// here with the page, since nothing in the runtime package itself depends on them.// dist/demo/ (not plain dist/) on purpose: slopbox.js and the shell test still say// "/dist/demo/terminal.js" etc, unchanged from when these bundles lived in the// runtime's own dist/demo/. Keeping the same shape here means those files needed no edits.const DIST = "dist/demo";const common = { bundle: true, target: "es2022", minify: true };
rmSync(DIST, { recursive: true, force: true });
await Promise.all([ // The terminal pane. The stylesheet loads as text so the bundle is one file that // injects its own CSS (xterm writes runtime CSS into <style> elements it creates, so // it can't be a plain <link>). build({ ...common, entryPoints: ["terminal.js"], format: "esm", outfile: `${DIST}/terminal.js`, loader: { ".css": "text" }, }), // The Shell tab's bash interpreter. Lazy-loaded (slopbox.js imports it only once the // tab is first chosen), so it is its own bundle rather than folded into slopbox.js. // bashkit's wasm binary ships alongside it, fetched relative to the bundle's own URL // (`new URL("./bashkit.wasm", import.meta.url)` in shell.js). build({ ...common, entryPoints: ["shell.js"], format: "esm", outfile: `${DIST}/shell.js`, }), // The npm gateways this build installs through (D23), named as a repo names its knot: a // DID or a hostname, resolved at boot to its #nibling_npm endpoint, so a gateway's operator // can move it without a rebuild. NIB_NPM_GATEWAYS is space-separated; unset is none, and // every install goes straight to the registry. build({ ...common, stdin: { contents: [ 'import { gatewaySources, resolveGateways } from "@nibling/npm-gateway/resolve";', `export const NAMES = ${JSON.stringify((process.env.NIB_NPM_GATEWAYS ?? "").split(/\s+/).filter(Boolean))};`, "export const resolve = () => resolveGateways(NAMES);", "export const sources = () => gatewaySources(NAMES);", ].join("\n"), resolveDir: ".", loader: "js", }, format: "esm", outfile: `${DIST}/npm-gateways.js`, }),]);mkdirSync(DIST, { recursive: true });copyFileSync( createRequire(import.meta.url).resolve("@everruns/bashkit-wasm/bashkit_wasm_bg.wasm"), `${DIST}/bashkit.wasm`,);console.log(`built ${DIST}/{terminal,shell,npm-gateways}.js, ${DIST}/bashkit.wasm`);