fix(local-llm): set Vite worker.format='es' for code-splitting support

The Phase 3 build failed at the worker bundling step with:
  "Invalid value 'iife' for option 'worker.format' - UMD and IIFE
  output formats are not supported for code-splitting builds."

Vite defaults workers to IIFE format which can't handle code-split
imports. @mana/local-llm's new worker.ts imports @huggingface/
transformers, which itself is internally code-split into many
chunks (the ONNX runtime, the model classes, the tokenizer
families, the lazy backend selectors). IIFE has no way to load
those at runtime.

Switch the web app's vite.config.ts to `worker: { format: 'es' }`.
Module workers are supported in every browser that supports
WebGPU (Chrome 80+, Edge 80+, Safari 15+), so no users lose
support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-09 01:33:03 +02:00
parent 45f368f471
commit 2d3c2bfc6f

View file

@ -56,6 +56,16 @@ export default defineConfig({
port: 4173,
strictPort: true,
},
worker: {
// Vite defaults to IIFE worker format, which does not support code
// splitting. @mana/local-llm's worker imports transformers.js, which
// is internally code-split into many chunks. Without 'es' format the
// build fails with "Invalid value 'iife' for option 'worker.format'
// - UMD and IIFE output formats are not supported for code-splitting
// builds." All modern browsers (which we already require for WebGPU)
// support module workers.
format: 'es',
},
ssr: {
// `rrule@2` ships dual CJS/ESM but its package.json has no `exports`
// field, so the SvelteKit Node adapter resolves it to the CJS bundle