rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.75k stars 211 forks source link

Answer in 4.2 exercise does not work. #261

Closed letto4135 closed 1 year ago

letto4135 commented 3 years ago

Describe the bug Everything seems to be working as expected until I get to the exercise. Updating the code and running wasm-pack build does nothing to the front end.

To Reproduce Steps to reproduce the behavior: Follow instructions up to the exercise in 4.2

Expected behavior The exercise should work.

Screenshots

Screen Shot 2021-09-28 at 8 39 28 PM Screen Shot 2021-09-28 at 8 39 46 PM Screen Shot 2021-09-28 at 8 40 21 PM
joshuaalm commented 2 years ago

I get the same behavior image image image

armenic commented 1 year ago

The reason is because npm install already captured the old version of wasm-game-of-life. To fix this:

  1. Up-version in the Cargo.toml, e.g. "0.1.1"
  2. Within the wasm-game-of-life directory run wasm-pack build
  3. Within the www directory run npm install wasm-game-of-life
  4. You might also need to stop and restart the local server

image

erikbrntsn commented 1 year ago

I have a similar problem. Only the result of the first compilation is ever used. Any changes after compiling the first time have no effect. I have tried changing the version in the cargo.toml + restarted the server + uninstall wasm-game-of-life and readded in to the dependencies section + removed the www app and recreated it. None of these steps help :(

The only way I have found to get around the problem is to remove the entire wasm-game-of-life folder and recreating it + applying all the changes to the code before running wasm-pack build

Note this is the case for the steps in the subsection "Implementing Life" as well

letto4135 commented 1 year ago

Sorry, I'm just going to close this. I can't remember at this point if I ever got it to work, and I don't have anything set up to know whether armenics answer works.

ptdecker commented 1 year ago

@armenic 's answer worked for me. I know this issue has been closed but it doesn't appear the instructions for the tutorial have been corrected (in fact, it doesn't seem like there is much activity towards maintaining this book unfortunately--lots of accumulated issues and pull requests that are unattended).