book icon indicating copy to clipboard operation
book copied to clipboard

Changes to code have no effect after first compilation

Open erikbrntsn opened this issue 2 years ago • 5 comments

Changes to code in the exercise of section 4.2 and later have no effect.

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 (as described in #261) + restarted the server + uninstall wasm-game-of-life from www 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 and not only in the exercise of section 4.2.

To Reproduce Follow every steps in the tutorial.

Expected behavior All changes to code are reflected in the behavior of the web app.

Additional context I am following the steps in the tutorial and I am pretty sure I have done everything exactly as described. The first changes to the code after first compilation are made in the exercise in 4.2. This I where the problem occurs the first time.

erikbrntsn avatar Nov 23 '22 08:11 erikbrntsn

I have found a simpler workaround.

After you have made your changes to your code and run wasm-pack build do the following:

Steps: remove "wasm-game-of-life": "../pkg" from the dependecies section of package.json run npm install re-add "wasm-game-of-life": "../pkg" to the dependencies run npm install stop the server run npm run start (possibly like this: NODE_OPTIONS=--openssl-legacy-provider npm run start)

I am pretty new to basically all the involved components of this (JS, npm, rust, wasm) so it is very likely there is a better way to accomplish the same in a simpler way. Please let me know

erikbrntsn avatar Nov 23 '22 14:11 erikbrntsn

I'm having the same issue. It looks like the files in pkg/ are copied into www/npm_modules/wasm-game-of-life/ instead of getting symlinked, and they don't get updated when wasm-pack build or npm install are re-run after editing src/lib.rs.

grampajoe avatar Nov 24 '22 22:11 grampajoe

~~Downgrading to [email protected] fixes this: npm install -g [email protected].~~

~~It could be a behavior change in 9.1? Possibly related: https://github.com/npm/cli/issues/5868~~

This is an intentional change in 9.0 (release notes):

install-links config defaults to "true"

The cleanest solution is probably to use npm link ../pkg from www/. The tutorial will need to be updated to reflect the change in npm behavior.

grampajoe avatar Nov 24 '22 22:11 grampajoe

I have the same problem after following just the very first part (Hello World) and running nom link ../pkg does not seem to have an effect.

geekynils avatar Dec 09 '22 16:12 geekynils

The cleanest solution is probably to use npm link ../pkg from www/. The tutorial will need to be updated to reflect the change in npm behavior.

Thank you!! I kept running into:

WARNING in ./index.js 4:17-25
"export 'Universe' was not found in 'wasm-game-of-life'
 @ ./bootstrap.js

and this fixed it.

CLEckhardt avatar Dec 11 '22 01:12 CLEckhardt