Publishing to npm

Now that we have a working, fast, and small wasm-game-of-life package, wecan publish it to npm so other JavaScript developers can reuse it, if they everneed 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 thiscommand:

  1. wasm-pack login

Publishing

Make sure that the wasm-game-of-life/pkg build is up to date by runningwasm-pack inside the wasm-game-of-life directory:

  1. wasm-pack build

Take a moment to check out the contents of wasm-game-of-life/pkg now, this iswhat we are publishing to npm in the next step!

When you're ready, run wasm-pack publish to upload the package to npm:

  1. wasm-pack publish

That's all it takes to publish to npm!

…except other folks have also done this tutorial, and therefore thewasm-game-of-life name is taken on npm, and that last command probably didn'twork.

Open up wasm-game-of-life/Cargo.toml and add your username to the end of thename to disambiguate the package in a unique way:

  1. [package]
  2. name = "wasm-game-of-life-my-username"

Then, rebuild and publish again:

  1. wasm-pack build
  2. wasm-pack publish

This time it should work!