heygen-com/hyperframes · error
Failed to bundle beat analyzer
Error message
Failed to bundle beat analyzer
What it means
Thrown by buildFromCoreSource() when esbuild.build() returns no outputFiles, which should not happen under normal operation — esbuild returns at least one output for a valid build. It indicates a degenerate esbuild result (empty output array) when bundling the beat-detection entry from @hyperframes/core source at runtime. This path runs only when no prebuilt bundle artifact (beat-analyzer.global.js) is found on disk.
Source
Thrown at packages/cli/src/beats/headlessAnalyzer.ts:52
const esbuild = await import("esbuild");
const coreRoot = dirname(require.resolve("@hyperframes/core/package.json"));
const entry = join(coreRoot, "src/beats/beatDetection.ts");
const result = await esbuild.build({
stdin: {
contents:
`import { analyzeMusicFromBuffer } from ${JSON.stringify(entry)};\n` +
`globalThis.__hfAnalyze = analyzeMusicFromBuffer;`,
resolveDir: coreRoot,
loader: "ts",
},
bundle: true,
format: "iife",
platform: "browser",
target: "es2020",
write: false,
});
const out = result.outputFiles?.[0];
if (!out) throw new Error("Failed to bundle beat analyzer");
return out.text;
}
function buildAnalyzerBundle(): Promise<string> {
if (bundlePromise) return bundlePromise;
bundlePromise = (async () => {
const prebuilt = findPrebuiltBundle();
if (prebuilt) return readFileSync(prebuilt, "utf8");
return buildFromCoreSource();
})().catch((err) => {
bundlePromise = null; // don't poison the process with a cached rejection
throw err;
});
return bundlePromise;
}
export interface HeadlessBeatResult {
beatTimes: number[];View on GitHub (pinned to c2996c8626)
Solutions
- Run `bun run build` to regenerate the prebuilt beat-analyzer.global.js artifact so the runtime bundling path is not taken.
- Verify @hyperframes/core/src/beats/beatDetection.ts exists and exports analyzeMusicFromBuffer; if it moved, update the entry path in buildFromCoreSource().
- Reinstall dependencies (`bun install`) to ensure esbuild is at the expected version.
Example fix
# before — no prebuilt bundle, esbuild returns empty $ bunx hyperframes beats track.mp3 # build the artifacts so the prebuilt path is used $ bun run build $ bunx hyperframes beats track.mp3
Defensive patterns
Strategy: try-catch
Validate before calling
import { existsSync } from 'node:fs';
function prebuiltBundlePresent(): boolean {
// Mirror findPrebuiltBundle candidates relevant to your install
return existsSync(require('path').join(__dirname, 'beat-analyzer.global.js'));
}
if (!prebuiltBundlePresent()) {
console.warn('No prebuilt beat analyzer bundle — run `bun run build` before using the beats command.');
} Try / catch
try {
await analyzeBeatsHeadless(buf);
} catch (err) {
if (/Failed to bundle beat analyzer/i.test((err as Error).message)) {
console.error('Beat analyzer bundle could not be built. Run `bun run build` and retry.');
}
throw err;
} Prevention
- Always run `bun run build` after pulling changes to regenerate the prebuilt analyzer bundle.
- In CI, build before invoking the beats command so the runtime esbuild path is never taken.
- Pin the esbuild version via the lockfile to avoid output-shape regressions.
When it happens
Trigger: analyzeBeatsHeadless() is called in a dev/monorepo context where findPrebuiltBundle() returns null, so buildAnalyzerBundle() calls buildFromCoreSource(); esbuild then returns an empty outputFiles array. Typically an esbuild version incompatibility or a malformed stdin entry.
Common situations: Running the CLI from source in the monorepo after @hyperframes/core's beatDetection.ts moved or was renamed; an esbuild upgrade changed output semantics; the entry path join(coreRoot, 'src/beats/beatDetection.ts') no longer resolves but esbuild returned an empty result instead of erroring.
Related errors
- [build-zip] hyperframe runtime artifacts missing under ${cor
- beat analyzer not loaded
- Missing browser script ${name}
- --source must be 'sparticuz' or 'chrome-headless-shell' (got
- Unknown flag: ${arg}
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/6023f72b5c5af885.
Report an issue: GitHub.