Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompileError using webpack: Missing mediainfo.wasm #32

Closed
nikitatrifan opened this issue Jun 7, 2020 · 6 comments
Closed

CompileError using webpack: Missing mediainfo.wasm #32

nikitatrifan opened this issue Jun 7, 2020 · 6 comments
Labels

Comments

@nikitatrifan
Copy link

nikitatrifan commented Jun 7, 2020

Hey there!

It seems like there is a bug. Here is what I'm getting when playing around with the library using create react app template:

Uncaught (in promise) RuntimeError: abort(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0). Build with -s ASSERTIONS=1 for more info.
    at abort (http://localhost:3000/static/js/1.chunk.js:3145:17)
    at http://localhost:3000/static/js/1.chunk.js:3239:15

That's how the lib is being imported:

import MediaInfo from 'mediainfo.js'

Any suggestions? Thanks!

@nikitatrifan
Copy link
Author

Just tested the minified version being loaded from unpkg and looks like it works properly. But compiling fails when I import it from node_modules.

@buzz
Copy link
Owner

buzz commented Jun 8, 2020

The WASM loader tries to load mediainfo.wasm. It determines the URL relative to mediainfo.js.
When using a CDN this just works because mediainfo.wasm is published in the dist folder.

When you're using a custom bundler build flow you need to make sure to copy mediainfo.wasm to your output directory. Check the source code of https://mediainfo.js.org/ on how this is achieved using webpack and copy-webpack-plugin.

Docs on using a JS bundler could be improved, I guess.

@buzz buzz closed this as completed Jun 8, 2020
@buzz buzz added the question label Jun 8, 2020
@buzz buzz changed the title RuntimeError CompileError using webpack: Missing mediainfo.wasm Jun 8, 2020
@dcfranca
Copy link

Is it possible to load the wasm on a create-react-app project without needing to eject it?

@buzz
Copy link
Owner

buzz commented Apr 30, 2021

Is it possible to load the wasm on a create-react-app project without needing to eject it?

As long as create-react-app is able to serve the WASM file via HTTP you're good to go. Usually it's sufficient to drop the file in a public folder or similar.

@dcfranca
Copy link

@buzz thanks for the quick reply

Just to clarify that I'm running on development mode

I've tried a few things:
I do have a public folder, so I copied the MediaInfoModule.wasm there, didn't work

I, then, copied both mediainfo.js and MediaInfoModule.wasm under my src folder, I understood that both need to be on the same folder... and changed the import to:
import MediaInfo from '<my_folder>/mediainfo.js';

Also didn't work

I feel that I'm missing something very silly here

The error message:

Uncaught RuntimeError: abort(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0). Build with -s ASSERTIONS=1 for more info.
abort @ <myDir>/src/static/mediainfo.js:42

@dcfranca
Copy link

I made it work loading from the CDN! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants