fix: add CommonJS compatibility for lamejs dynamic import

Fixed MP3 export error by handling both default and named exports
from lamejs module to support CommonJS/ESM interop.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-19 07:52:17 +01:00
parent df1314a37c
commit 8112ff1ec3

View File

@@ -136,8 +136,9 @@ export async function audioBufferToMp3(
audioBuffer: AudioBuffer,
options: ExportOptions = { format: 'mp3', bitrate: 192 }
): Promise<ArrayBuffer> {
// Dynamically import lamejs
const lamejs = await import('lamejs');
// Dynamically import lamejs - use default export for CommonJS compatibility
const lameModule = await import('lamejs');
const lamejs = lameModule.default || lameModule;
const { bitrate = 192, normalize } = options;
const numberOfChannels = Math.min(audioBuffer.numberOfChannels, 2); // MP3 supports max 2 channels