WASM: Cant’t resolve `env`

Bug report

What is the current behavior?
When importing a WASM file from mediainfo.js, I am getting 2 errors:

ERROR in ./app/client/lib/mediainfo.wasm
Module not found: Error: Can't resolve 'env' in '/path/app/client/lib'
 @ ./app/client/lib/mediainfo.wasm
ERROR in ./app/client/lib/mediainfo.wasm
Module not found: Error: Can't resolve 'global.Math' in '/path/app/client/lib'
 @ ./app/client/lib/mediainfo.wasm

If the current behavior is a bug, please provide the steps to reproduce.
WASM file can be found here: https://www.dropbox.com/s/58e4h04pg71wug9/mediainfo.wasm?dl=0 (4 MB). It is compiled from https://github.com/buzz/mediainfo.js using em++ -Os --llvm-lto 0 -s TOTAL_MEMORY=1073741824 -s NO_FILESYSTEM=1 -s MODULARIZE=1 --bind mediainfojs.o MediaInfoLib/Project/GNU/Library/.libs/libmediainfo.a ZenLib/Project/GNU/Library/.libs/libzen.a Shared/Source/zlib/libz.a -o mediainfo.js

Module rule for WASM is from the example:

  test: /\.wasm$/,
  type: "webassembly/experimental",

It does not compile a simple file:

async function test() {
  const mediainfo = await import("lib/mediainfo.wasm")

What is the expected behavior?

The WASM file should be loadable by import and added to the build outputs.
If this is an expected error (this is my first try with “real” WASM), I havent been able to find a clue anywhere.

Other relevant information:
webpack version: 4.8.3
Node.js version: 10.1.0
Operating System: MacOS 10.13.4
Additional tools: emscripten 1.18.1

Author: Fantashit

1 thought on “WASM: Cant’t resolve `env`

  1. Ok thanks. I will try the workaround you mentioned in the other issue.
    I am not sure how, but maybe this should be mentioned somewhere (doc? error message?), I guess I wont be the only one trying to run emscripten-compiled code.

Comments are closed.