Haygen
Decisions/ADR-004-vitest-inline-deps.md
ADR-004: @heygen/streaming-avatar Must Be Inlined in vitest
Decision
vitest.config.ts includes server: { deps: { inline: ['@heygen/streaming-avatar'] } }.
Context
@heygen/streaming-avatar declares "type": "module" (ESM package) but its "main" field points to a CJS file. When vitest's Node runner loads it, it hits the CJS file in an ESM context and throws:
ReferenceError: exports is not defined in ES module scope
Fix
server.deps.inline forces Vite to process the package through its bundler pipeline, which uses the "module" field (the actual ESM build) instead of "main". This resolves the CJS/ESM conflict.
Consequence
The SDK is bundled into the test output rather than loaded from node_modules at runtime. No functional impact on test correctness. Tests run normally.