Skip to content

fix(app): bundle onnxruntime-web into the TTS worker - #71

Merged
kixelated merged 3 commits into
mainfrom
fix/vite-onnxruntime
Nov 26, 2026
Merged

kixelated merged 3 commits into
mainfrom
fix/vite-onnxruntime

Conversation

@kixelated

@kixelated kixelated commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

app/vite.config.ts marked onnxruntime-web external for both the app and worker builds. Nothing maps that bare specifier at runtime, so the built Kokoro TTS worker starts with import*as e from"onnxruntime-web" and fails to load: High-quality TTS is broken in production. Found while working on #65 (closed), whose closing comment asked for this fix to land separately.

Approach

Drop the external from build.rolldownOptions and worker.rolldownOptions, so Vite bundles ORT's JS into the lazy TTS worker. transformers.js still points ORT at its jsdelivr WASM by default, as before.

Impact

  • Public API / wire: none.
  • Initial index chunk: unchanged (1,218,156 bytes before and after).
  • TTS worker: 1.83 MB to 2.22 MB, loaded only when High TTS is on.
  • dist/ gains a 21.6 MB ort-wasm-simd-threaded.jsep .wasm asset (5.2 MB gzip), under Cloudflare's 25 MiB per-file limit. Not fetched by the initial page; dropping it needs a custom plugin, not worth it while the TTS quest (quest/m2/tts-phonon.md, planned in quest: plan captions from moq.pro transcripts and TTS on Phonon #72) removes ORT from TTS.

Caused by

No single PR: the external came from direct commits to main in 2025 (f8a3bf0 "Don't bundle all of ONNX.", a825fa5 "Avoid bundling the ORT WASM blob too.").

Validation

  • quest gate just build on main: the built worker-*.js contains import*as e from"onnxruntime-web". With the fix, no chunk has a bare onnxruntime-web import.
  • Real surface: served both dist/ builds and constructed the built TTS worker as a module worker in Chrome (agent-browser). main's worker fired an error event (script failed to load); the fixed worker loaded with no error.
  • Not validated: speaking a message end to end, since that needs a hardware WebGPU adapter no agent host has.
  • quest gate just check passes.
  • After merging main (8802dca): CI Check (just check && just build, including test:media) passes. Locally, quest gate just check passed everything up to test:media, whose browser tests timed out at a host load average of ~27; a rerun timed out in its setup hook. The change only touches production build options, which the Vite dev server those tests run on does not read.
  • After merging main again (69b7aa8, conflict-free, picks up quest: audit the quest tree #58 and feat(room): live MoQ telemetry HUD in Debug mode #64): quest gate just build passes and still emits ort-wasm-simd-threaded.jsep-*.wasm; CI Check passes. Locally test:media again timed out under host load (~25 on 2 CPUs), as above.

Models

Size: XS
Implementer: Claude Code, claude-opus-5-5, medium
Implementer: Claude Code, claude-opus-5-5, medium effort (iterate, XS)
Implementer: Claude Code, claude-opus-5-5, medium effort (iterate, XS)

(Written by Claude Opus 5.5 with medium)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 8802dca

  • Base: origin/main at 51647b2

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Risk file: none

  • Reviewer: Codex, gpt-6.2-sol, low effort

  • Session: 01a219d4-9a6f-79d2-ad01-47daeaaad558, round 1

  • Score: 9/10, Bundling ONNX Runtime makes the dependency resolvable in the production TTS worker while preserving lazy loading, with only stale planning references remaining.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Notes, the author's to take or leave:

    • app/vite.config.ts:24: Remove stale references to the ONNX Runtime workaround

Marking onnxruntime-web external left a bare import "onnxruntime-web"
in the built Kokoro worker, which a browser cannot resolve, so
High-quality TTS failed to load in production.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Vite configuration removes the onnxruntime-web externalization setting from the build and removes the worker’s rolldownOptions.external setting. The build target, source-map, and input settings remain.

Merge Risk: Minimal · up to 8802d

This change bundles ONNX Runtime's JavaScript into the lazy-loaded TTS worker, so High-quality TTS can load in production instead of failing on an unresolved import. The TTS worker grows by about 0.4 MB and the build adds a 21.6 MB WASM asset that the initial page does not fetch. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(app): bundle onnxruntime-web into the TTS worker" matches the changeset. The diff removes the onnxruntime-web external setting from the build and worker rolldownOptions in app/vite.conf…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states that the change removes the onnxruntime-web external setting from the build and worker configs in app/vite.config.ts so Vite bundles ORT JavaScript into the lazy-loaded TTS work…
Full details: Title check

Explanation

The title "fix(app): bundle onnxruntime-web into the TTS worker" matches the changeset. The diff removes the onnxruntime-web external setting from the build and worker rolldownOptions in app/vite.config.ts, so Vite bundles ORT JavaScript into the lazy TTS worker. The title is specific, short, and names the main change, and it does not use vague terms.

Full details: Description check

Explanation

The description states that the change removes the onnxruntime-web external setting from the build and worker configs in app/vite.config.ts so Vite bundles ORT JavaScript into the lazy-loaded TTS worker. It gives the problem, approach, bundle-size impact, causing commits, and validation steps. This matches the raw summary and the PR objectives, so the description is related to the changeset.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e0277e03-b5bb-401f-8fa6-f5dbf4039cef
Commits

Reviewing files that changed from the base of the PR and between 51647b2 and 8802dca.

Files selected for processing: 1

  • app/vite.config.ts
Files with no reviewable changes: 1

  • app/vite.config.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (via /quest-run): ✅ /quest-merge this PR (rejected: skip until Phonon, iterate).

(Written by Claude Opus 5.5)

@kixelated
kixelated merged commit 212ddf5 into main Nov 26, 2026
2 checks passed
@kixelated
kixelated deleted the fix/vite-onnxruntime branch November 26, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant