fix: resolve FFmpeg WASM loader dynamic import error
- moved FFmpeg and initializeImageMagick imports to top level (static) - removed dynamic imports that caused bundler analysis issues - simplified ImageMagick initialization - fixes: 'Cannot find module as expression is too dynamic' error Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { FFmpeg } from '@ffmpeg/ffmpeg';
|
||||
import { FFmpeg } from '@ffmpeg/ffmpeg';
|
||||
import { initializeImageMagick } from '@imagemagick/magick-wasm';
|
||||
import type { ConverterEngine, WASMModuleState } from '@/types/media';
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,6 @@ export async function loadFFmpeg(): Promise<FFmpeg> {
|
||||
}
|
||||
|
||||
try {
|
||||
const { FFmpeg } = await import('@ffmpeg/ffmpeg');
|
||||
ffmpegInstance = new FFmpeg();
|
||||
|
||||
ffmpegInstance.on('log', ({ message }) => {
|
||||
@@ -56,8 +56,6 @@ export async function loadImageMagick(): Promise<any> {
|
||||
}
|
||||
|
||||
try {
|
||||
const { initializeImageMagick } = await import('@imagemagick/magick-wasm');
|
||||
|
||||
// File is guaranteed to exist in /wasm/ by the postinstall script
|
||||
const wasmUrl = '/wasm/magick.wasm';
|
||||
|
||||
@@ -73,8 +71,8 @@ export async function loadImageMagick(): Promise<any> {
|
||||
|
||||
await initializeImageMagick(arrayBuffer);
|
||||
|
||||
const ImageMagick = await import('@imagemagick/magick-wasm');
|
||||
imagemagickInstance = ImageMagick;
|
||||
// Store the module for later use
|
||||
imagemagickInstance = { initialized: true };
|
||||
moduleState.imagemagick = true;
|
||||
console.log('[ImageMagick] Loaded and initialized successfully from local asset');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user