Publishing to npm¶
Now that we have a working, fast, and small wasm-game-of-life package, we can publish it to npm so other JavaScript developers can reuse it, if they ever need an off-the-shelf Game of Life implementation.
Prerequisites¶
First, make sure you have an npm account.
Second, make sure you are logged into your account locally, by running this command:
1 | |
Publishing¶
Make sure that the wasm-game-of-life/pkg build is up to date by running wasm-pack inside the wasm-game-of-life directory:
1 | |
Take a moment to check out the contents of wasm-game-of-life/pkg now, this is what we are publishing to npm in the next step!
When you're ready, run wasm-pack publish to upload the package to npm:
1 | |
That's all it takes to publish to npm!
...except other folks have also done this tutorial, and therefore the wasm-game-of-life name is taken on npm, and that last command probably didn't work.
Open up wasm-game-of-life/Cargo.toml and add your username to the end of the name to disambiguate the package in a unique way:
1 2 | |
Then, rebuild and publish again:
1 2 | |
This time it should work!