rustwasm / team

A point of coordination for all things Rust and WebAssembly
MIT License
1.45k stars 59 forks source link

Error when following MDN WASM Guide #255

Closed ReidAnderson closed 5 years ago

ReidAnderson commented 5 years ago

Hello,

I attempted to follow along with the MDN guide for compiling simple Rust to wasm. Each step worked without error until I attempted to run the web pack server, at which point the below error was thrown:

ERROR in ./node_modules/@andereid/hello-wasm/hello_wasm_bg.wasm
Module parse failed: Unexpected section: 0xfe
You may need an appropriate loader to handle this file type.
Error: Unexpected section: 0xfe
    at new CompileError (.........
 @ ./node_modules/@andereid/hello-wasm/hello_wasm.js 2:0-40 8:71-82 9:45-56 30:16-38 43:15-25 46:8-28
 @ ./index.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./index.js

ERROR in chunk 0
3e2522591534271b41d1.module.wasm
C:\.....\node_modules\@andereid\hello-wasm\hello_wasm_bg.wasm
unexpected end

I went out to npm and just tried pulling in an npm package from someone else that had been published from the tutorial, and that did work. However going to that repo, cloning it locally, running wasm-pack build --scope mynpmusername, pushing it up to npm, and then pulling it to run through webpack resulted in the same error above. That leads me to believe that it has to be something with how I'm compiling the Rust to WebAssembly, but I don't have the skills to troubleshoot. Let me know if there's anything further I can provide.

OS: Windows 10 wasm-pack 0.6.0 rustc 1.32.0 (9fda7c223 2019-01-16) cargo 1.32.0 (8610973aa 2019-01-02)

xtuc commented 5 years ago

Duplicated of https://github.com/webpack/webpack/issues/8781.