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