From 6d4426037c316cbf1ffb580f003dbcb4909e3c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Wed, 25 Feb 2026 20:29:55 +0100 Subject: [PATCH] Fix FFmpeg import: use direct import like ImageMagick Import FFmpeg at module level instead of dynamic import. The build now compiles cleanly without Turbopack bundler warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/media/wasm/wasmLoader.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/media/wasm/wasmLoader.ts b/lib/media/wasm/wasmLoader.ts index ee02f6d..24bf176 100644 --- a/lib/media/wasm/wasmLoader.ts +++ b/lib/media/wasm/wasmLoader.ts @@ -1,9 +1,6 @@ -// Suppress Turbopack bundler warning for FFmpeg's dynamic imports -// The @ffmpeg/ffmpeg package internally uses dynamic imports that Turbopack -// flags as "too dynamic" but still work at runtime -declare const globalThis: any; - import type { ConverterEngine, WASMModuleState } from '@/types/media'; +import type { FFmpeg as FFmpegType } from '@ffmpeg/ffmpeg'; +import { FFmpeg } from '@ffmpeg/ffmpeg'; import { initializeImageMagick } from '@imagemagick/magick-wasm'; /** @@ -17,23 +14,18 @@ const moduleState: WASMModuleState = { /** * Cached WASM instances */ -let ffmpegInstance: any = null; +let ffmpegInstance: FFmpegType | null = null; let imagemagickInstance: any = null; /** * Load FFmpeg WASM module */ -export async function loadFFmpeg(): Promise { +export async function loadFFmpeg(): Promise { if (ffmpegInstance && moduleState.ffmpeg) { return ffmpegInstance; } try { - // Import FFmpeg at runtime to avoid static bundler analysis - // The @ffmpeg/ffmpeg package has internal dynamic imports that - // Turbopack cannot statically analyze, but they work fine at runtime - const { FFmpeg } = await import('@ffmpeg/ffmpeg'); - if (!FFmpeg) { throw new Error('FFmpeg class not available'); }