Skip to content

Replace fragile Vite ONNX plugin with standard solution #13

Description

@Lucasmind

Priority: LOW

Problem

The custom serveOnnxFiles() Vite plugin manually parses URLs to serve ONNX WASM files. This is fragile and could break if the path structure of the onnxruntime-web package changes in future versions.

Current Implementation

// vite.config.js - serveOnnxFiles() plugin
// Manually intercepts requests and serves .wasm files from node_modules

Suggested Fix

Investigate using standard Vite WASM plugins:

  • vite-plugin-wasm
  • @aspect-build/rules_wasm
  • Or a simpler approach: copy WASM files to public/ at build time
// Option: Copy plugin
{
  name: 'copy-onnx-wasm',
  buildStart() {
    // Copy ort-wasm*.wasm files to public/
  }
}

Considerations

  • Must maintain compatibility with vad-web (CJS module, see CLAUDE.md)
  • talkinghead uses dynamic workers and MUST stay excluded from optimizeDeps
  • After any changes: delete node_modules/.vite cache and test thoroughly

Files Affected

  • frontend/vite.config.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions