Skip to content

template-sdk: CJS-only build breaks default import under esbuild-style interop (vite 8/Rolldown, bun build) — egress aborts with "Start signal not received" #1286

Description

@livekit/egress-sdk (0.2.1) ships CJS only — package.json has "main": "dist/index.js" with no exports map or ESM build, and dist/index.js uses exports.__esModule = true + exports.default = EgressHelper.

Bundlers with esbuild-style CJS interop (Rolldown — vite 8's default bundler — and bun build) bind import EgressHelper from "@livekit/egress-sdk" to the module namespace object instead of unwrapping .default, unlike Rollup/vite ≤ 7. Every method access then throws (EgressHelper.getLiveKitURL is not a function), so a custom room-composite template never emits START_RECORDING, and the egress aborts with Start signal not received — silently losing recordings, with nothing in the page console (a guard try/catch around the param getters swallows the TypeError). We hit this in production use the day Dependabot bumped vite 7 → 8.

Repro

// probe.ts
import EgressHelper from "@livekit/egress-sdk";
console.log(typeof (EgressHelper as any).getLiveKitURL, Object.keys(EgressHelper as any));
  • bun build probe.ts --target=browser (or vite build on vite 8 / Rolldown): undefined [ "default" ]
  • vite ≤ 7 (Rollup) or the Bun runtime: function [ "getLiveKitURL", "getAccessToken", … ]

The runtime-vs-bundler disagreement makes it particularly nasty: dev mode and tests pass, only the production bundle breaks, and the first observable symptom is EGRESS_ABORTED "Start signal not received" on the egress side.

Ask

Publish a dual ESM/CJS build — an exports map with an import condition is enough (the package is ~100 lines). Happy to send a PR to template-sdk/ if that helps.

Workaround for anyone else hitting this

import EgressHelperImport from "@livekit/egress-sdk";
const EgressHelper =
  (EgressHelperImport as unknown as { default?: typeof EgressHelperImport }).default ??
  EgressHelperImport;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions