#!/usr/bin/env node // Copies the worker into the adapter build output. It is spawned by // path at runtime, so Vite doesn't emit it and we place it ourselves. // // The worker ships as TypeScript and node strips the types on load, the same way // the deploy runs scripts/migrate.ts. Its imports stay relative or bare so plain // node can resolve them against the release's node_modules. // // Runs after `vite build` (see package.json). The deploy rsyncs the whole build/ // dir, so anything landed here ships as-is. import { copyFile, mkdir } from 'node:fs/promises' import { fileURLToPath } from 'node:url' import { dirname, join } from 'node:path' const root = join(dirname(fileURLToPath(import.meta.url)), '..') const build = join(root, 'build') const WORKER_FILES = [ 'audio-worker.ts', 'spectrogram-analyse.ts', 'transcode.ts', 'audio.ts' ] async function main() { await mkdir(join(build, 'workers'), { recursive: true }) for (const file of WORKER_FILES) { await copyFile( join(root, 'src/lib/server/blob', file), join(build, 'workers', file) ) } console.log('postbuild: copied workers/ into build/') } main().catch((err) => { console.error('postbuild failed:', err) process.exit(1) })