ffmpeg.wasm icon indicating copy to clipboard operation
ffmpeg.wasm copied to clipboard

Default core path can be incorrect

Open JackCA opened this issue 3 years ago • 2 comments

Describe the bug Similar to https://github.com/ffmpegwasm/ffmpeg.wasm/issues/374, the defaultOptions method (which is called as a side-effect upon importing the library) can trigger the following error in a development environment:

error - ../../node_modules/@ffmpeg/ffmpeg/src/browser/defaultOptions.js:7:0
Module not found: Can't resolve '/node_modules/@ffmpeg/core/dist/ffmpeg-core.js'

Import trace for requested module:
../../node_modules/@ffmpeg/ffmpeg/src/browser/index.js
../../node_modules/@ffmpeg/ffmpeg/src/index.js

To Reproduce

  • try and import the library in a development environment like next.js where the assets are hashed

Expected behavior

  • I am overriding the corePath myself in createFFmpeg and will never be using these defaultOptions -- perhaps defaultOptions should be lazily evaluated when needed, instead of being assigned immediately upon importing the library

JackCA avatar Aug 18 '22 18:08 JackCA

How did you end up overriding this? By simply importing @ffmpeg/ffmpeg into my next.js project I get this error.

zinkkrysty avatar Aug 19 '23 19:08 zinkkrysty

I managed to fix it in my Next.js app, by overriding the webpack config:

// next.config.js

const nextConfig = {
    // Solve misconfigured/missing imports from canvas-record
    webpack: (config) => {
        config.resolve.alias['/node_modules/@ffmpeg/core/dist/ffmpeg-core.js'] =
            '/node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js';
        config.resolve.alias['fs'] = false;
        return config;
    },
}

module.exports = nextConfig;

zinkkrysty avatar Aug 20 '23 14:08 zinkkrysty