// Bundles the SvelteKit adapter-node output into a single self-contained // file so the runtime image can ship without node_modules. // // Input: build/index.js (+ its static + dynamic imports from build/**) // Output: build/bundle.mjs // // Dropping node_modules shrinks the image from ~130 MB to ~60 MB. import { build } from 'esbuild'; await build({ entryPoints: ['build/index.js'], bundle: true, platform: 'node', format: 'esm', outfile: 'build/bundle.mjs', // Keep node built-ins external; bundle everything else (including deps // pulled in transitively by @sveltejs/kit, valibot, etc.). external: ['node:*'], // ESM output lacks the CommonJS `require` global; some transitive deps // call it via interop helpers. This shim makes it available. banner: { js: "import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);" }, // Dynamic imports in manifest.js reference hashed chunks by string // literal — esbuild statically traces these, no splitting needed. logLevel: 'info' });