Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create npm installer #738

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented Nov 11, 2019

This PR creates an npm installer for wasm-pack that downloads and installs a binary. It uses this unpublished package for installing binaries https://github.com/everlastingbugstopper/binary-install.

It currently downloads from a workers.cloudflare endpoint that we'd likely want to change to something that the rustwasm working group has control over.

We also probably want some more keywords before this would be published - currently I've just copied the same tags from the repository.

Proof that it works

$ cd ./wasm-pack/npm
$ npm i -g

> wasm-pack@0.8.1 postinstall 
> node -e 'require("./binary.js").install()'

Downloading release https://workers.cloudflare.com/get-binary/rustwasm/wasm-pack/v0.8.1/x86_64-apple-darwin.tar.gz
wasm-pack has been installed!
+ wasm-pack@0.8.1
updated 1 package in 1.317s                                                                                                                                                        
$ which wasm-pack
~/.nvm/versions/node/v13.1.0/bin/wasm-pack                                                                                                                                                         
$ wasm-pack
wasm-pack 0.8.1
Ashley Williams <ashley666ashley@gmail.com>
πŸ“¦ ✨  pack and publish your wasm!

USAGE:
    wasm-pack [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Log verbosity is based off the number of v used

SUBCOMMANDS:
    build      πŸ—οΈ  build your npm package!
    help       Prints this message or the help of the given subcommand(s)
    login      πŸ‘€  Add an npm registry user account! (aliases: adduser, add-user)
    pack       🍱  create a tar of your npm package but don't publish!
    publish    πŸŽ†  pack up your npm package and publish!
    test       πŸ‘©β€πŸ”¬  test your wasm!

Uninstalling will remove the downloaded binary, and installing a new version will overwrite the old downloaded binary.

Some caveats:

The README will need to be updated on every wasm-pack release, and the version number in package.json will also need to be bumped on every release.

Fixes #321

@ashleygwilliams ashleygwilliams modified the milestones: 0.10.0, 0.9.0 Nov 11, 2019
@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/create-npm-installer branch 6 times, most recently from e572aa3 to c7dd6db Compare November 11, 2019 20:57
@Pauan
Copy link
Contributor

Pauan commented Nov 11, 2019

Thanks a lot for starting on this!

I wonder if we could just create an npm package which contains the pre-built binaries (and a simple script as a fallback), and then just publish that.

That avoids needing to manage our own hosting, and it also means that versioning will work correctly (including version locking).

The alternative would be to point to the release files already hosted on GitHub, this strategy is used by PureScript.

@EverlastingBugstopper
Copy link
Contributor Author

EverlastingBugstopper commented Nov 11, 2019

Hosting is definitely something to consider.

The alternative would be to point to the release files already hosted on GitHub, this strategy is used by PureScript.

That's what the workers.cloudflare link is doing except that it also caches downloads so we don't run into Github rate limits.

EDIT: The source code for that worker script is open source: https://github.com/cloudflare/lasso/blob/master/cache-dependency-binary/index.js and Cloudflare Workers has a free tier so setting up a gateway like this shouldn't be cost prohibitive. Disclaimer: I work for Cloudflare πŸ˜„

@Pauan
Copy link
Contributor

Pauan commented Nov 11, 2019

My understanding is that GitHub has no rate limits on releases. I assume that they also heavily cache it, because the releases are immutable and cannot change.

@EverlastingBugstopper
Copy link
Contributor Author

EverlastingBugstopper commented Nov 11, 2019

Well in that case let's just use the Github releases! I've updated the PR to pull directly from Github.

@ashleygwilliams ashleygwilliams merged commit 3ced0eb into rustwasm:master Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a wasm-pack npm module that installs wasm-pack
3 participants