tts-voice-creator-clone-and.../scripts/minify.mjs
mARTin-B78 40e42590cc Release v1.6.0: a11y (WCAG AA), i18n (DE), PWA, perf, tests, Cast UX
Cast: card/list views, sort & filter, online voice picker, "Hear a line"
sample button, AI character notes, import auto-save.

Platform: WCAG 2.1 AA accessibility pass; German UI translation + language
picker; installable PWA with offline shell; GZip + content-visibility
virtualization + lazy images + Rehearser PCM memory cap (mobile stability);
Playwright suite (desktop + iPhone); opt-in minified bundle build.

Fixes: screenplay parser false characters; Fish-Speech inline-tag tones;
narrator/voice pickers list full library; clone GUI rework; fish.audio
import dedup; voice-ID rename; bulk-delete modal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 14:23:35 +02:00

43 lines
1.8 KiB
JavaScript

// Build an opt-in production bundle WITHOUT changing runtime semantics.
//
// The feature modules share a single global scope and are executed in a fixed order
// (see loader.js). We therefore CONCATENATE them in that exact order into one file and
// minify whitespace/syntax only — identifiers are kept, because inline HTML handlers
// (onclick="navTo(...)") and cross-file references rely on global names.
//
// Run: npm run minify → static/dist/main.min.js
// Enable at runtime with window.APP_USE_BUNDLE=true (or ?bundle=1). Default stays
// per-file so editing static/js/* is live without a rebuild.
import { transform } from 'esbuild';
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
const jsDir = join(root, 'static', 'js');
const outDir = join(root, 'static', 'dist');
mkdirSync(outDir, { recursive: true });
// Must match loader.js batch C order exactly.
const MAIN = [
'voice-picker', 'voice-inspector', 'voice-sources', 'fishaudio-browser',
'integrations', 'routing', 'voice-clone', 'voice-library', 'tts-preview',
'benchmark', 'stt', 'rehearser-parse', 'rehearser',
].map(n => join(jsDir, n + '.js'));
const source = MAIN.map(f => `\n/* ==== ${f.split('/').pop()} ==== */\n` + readFileSync(f, 'utf8')).join('\n');
const { code } = await transform(source, {
loader: 'js',
minify: false,
minifyWhitespace: true,
minifySyntax: true,
minifyIdentifiers: false, // keep global names referenced by HTML & other files
legalComments: 'none',
target: ['es2019', 'safari14'],
});
const out = join(outDir, 'main.min.js');
writeFileSync(out, code);
console.log(`Bundled ${MAIN.length} modules → static/dist/main.min.js (${(code.length / 1024).toFixed(0)} KB)`);