☀️ 0.5.0
-
✨ Features
-
Website! - ashleygwilliams, pull/246
We have a website now. It has the installer and links to documentation. In the future,
we hope to have calls to action for folks first coming to the site who are looking to
do specific things- these will help them find the docs and tutorials they need to.This PR also has a complete rework of our documentation.
Check it out here!
-
🍱 Module Support
-
BREAKING: use correct
package.json
keys for generated JavaScript - ashleygwilliams, issue/309 pull/312This is marked as potentially breaking because it changes the
package.json
keys that
are generated by the project.Previously, we generated a JavaScript file and placed it in the
main
key, regardless
of what you were targeting, ES6 and Node.js alike.We have received a lot of requests for
wasm-pack
to generate "isomorphic" packages,
that contain assets that could work on both Node.js and ES6, and this led to us
looking more closely at how we are usingpackage.json
.With this release, we will do the following:
-
--target broswer
: By default, we generate JS that is an ES6 module. We used to put
this in themain
field. Now we put it in themodule
field. We also add
sideEffects: false
so that bundlers that want to tree shake can. -
--target nodejs
: This target doesn't change. We put generated JS that is a
CommonJS module in themain
key. -
--target no-modules
: This is a new target. For this target we generate bare JavaScript.
This code is put in abrowser
field.
You can see the structs that represent each target's expected
package.json
here.Thanks so much to bterlson for his help in sorting this out for us!
-
-
-
🛠️ New Commands
-
wasm-pack init
is nowwasm-pack build
- csmoe, issue/188 pull/216When this project was first conceived, we imagined it would be simply a way to package
up generate wasm and js and publish it to npm. Here we are at version0.5.0
and we
have become much more- an integrated build tool!As a result, the original command
init
does a lot more than that these days. We've
renamed the command to better reflect the work it's actually doing.init
will still
work, but is deprecated now, and we will eventually remove it. -
add new command:
wasm-pack test
- fitzgen, pull/271This is an experimental new command that will run your tests in Node.js or a headless
browser usingwasm-pack test
. Check out this tutorial
to learn more! -
add 2FA support to
wasm-pack publish
- mstallmo, issue/257 pull/282We've been wrapping the
npm login
andnpm publish
commands aswasm-pack login
andwasm-pack publish
for a while now- but we didn't fully support two factor
authentication. Now we do! (Be safe out there! 2FA is good for everyone!)
-
-
🎏 New Flags
-
New target, bare JavaScript:
--target no-modules
- ashleygwilliams, issue/317 pull/327wasm-bindgen
offers ano-modules
flag that until now, we didn't support. This flag
produces bare, no modules JavaScript. So if that's your thing, this target is for you! -
--access
flag forwasm-pack
publish - ashleygwilliams, issue/297 pull/299Many of our tutorials use scopes to help prevent folks from attempting to publish
packages that will lead to npm Registry errors because the package name already exists.However, by default, scoped packages are assumed by the npm registry to be private, and
the ability to publish private packages to the npm registry is a paid feature. Worry not!
Now you can pass--access public
towasm-pack publish
and publish scoped packages
publicly.
-
-
✅ New Checks
-
rustc version check - ashleygwilliams, issue/351 pull/353
Now that we have a new fangled installer, there's a chance that folks might install
wasm-pack
and not have Rust installed. Additionally, now that the features we required from thenightly
channel of Rust have moved tobeta
- we don't need to enforcenightly
.As of this release, we will check that your Rust version is above
1.30.0
. You can be on
either thenightly
orbeta
channel and all ofwasm-pack
s calls tocargo
will
respect that.Really hate this? You can pass
--mode force
towasm-pack
to skip this check. I hope you know
what you're doing! -
coordinating wasm-bindgen versions and installing from binaries for improved speed - datapup, issue/146 pull/244 pull/324
This is the true gem of this release. Have you been frustrated by how long
wasm-pack
takes to
run? Overusing--mode no-install
? This is the release you're looking for.Many releases back we realized that folks were struggling to keep the
wasm-bindgen
library
that their project used in sync with thewasm-bindgen
CLI application whichwasm-pack
runs for you. This became such an issue that we opted to force installwasm-bindgen
to ensure
that everywasm-pack
user had the latest version.Like many technical solutions, this solved our original problem, but caused a new one. Now, we
we are forcing acargo install
ofwasm-bindgen
on every run, and that means downloading
and compilingwasm-bindgen
everytime you want to runwasm-pack
. That's unacceptable!We're happy to announce that we have a pretty great solution, and several more planned for
future releases. As of this release, we will read yourCargo.lock
to find the version of
wasm-bindgen
you are using in your local project. We will attempt to fetch a binary version
ofwasm-bindgen
that matches your local version. We place that binary local to your project,
and use it when you runwasm-pack build
. The next time you runwasm-pack build
we'll use
that binary, instead of fetching a new one. We still fall back tocargo install
for
less common architectures but this is a huge speed improvement. Check out these benchmarks!wasm-pack
v0.4.2$ time wasm-pack init # fresh build real 1m58.802s user 14m49.679s sys 0m24.957s $ time wasm-pack init # re-build real 0m56.953s user 11m12.075s sys 0m18.835s $ time wasm-pack init -m no-install # re-build with no-install real 0m0.091s user 0m0.052s sys 0m0.042s
wasm-pack
v0.5.0$ time wasm-pack build # fresh build real 1m3.350s user 3m46.912s sys 0m6.057s $ time wasm-pack build # re-build real 0m0.230s user 0m0.185s sys 0m0.047s $ time wasm-pack build -m no-install # re-build with no-install real 0m0.104s user 0m0.066s sys 0m0.041s
-
enforce
cargo build
with--lib
- ashleygwilliams, issue/303 pull/330Right now,
wasm-pack
only works on Rust library projects. But sometimes, if you're
new to Rust, you might end up having amain.rs
in your project, just by mistake.
Some folks ran into this and realized that it can cause issues!As a result, we are enforcing that
cargo build
only build the library at this time.Want to use
wasm-pack
on a binary application? We're interested in hearing from you!
Checkout issue/326 and please comment! We want to support binary applicaitons in
the future and are always happy and curious to hear about how folks usewasm-pack
!
-
-
Installers and Releases
-
Appveyor Windows Pre-Built binaries - alexcrichton, issue/147 pull/301
We finally got Appveyor to publish pre-built binaries to GitHub releases.
Aside: I really wish there were an easier way to test and debug this stuff. -
new experimental installer - alexcrichton, pull/307
Whew, this one is exciting. Up until now,
wasm-pack
has been distributed using
cargo install
. This is not ideal for several reasons. Updating is confusing,
and every time it's installed the user has to wait for it to compile- right at the
moment they just want to hurry up and use it already.Say hello to the new
wasm-pack
installer- we have an executable for Windows
and acurl
script for *nix users. Not pleased with that? File an issue for your
preferred distribution method and we'll do our best to get it working!This is experimental- so please try it out and file issues as you run into things!
You'll always be able to usecargo install
as a backup.Checkout the new installer here!
-
-
-
🛠️ Maintenance
-
📖 Documentation
-
improve readability of warnings about missing optional fields - twilco, pull/296
A little punctuation goes a long way. Error message improvement PRs are the best.
-
update links in README - alexcrichton, pull/300
We had a real dicey documentation situation for a while. Sorry about that, and thank
you SO MUCH to all the folks who filed PRs to fix it. -
fix broken links in book by using relative paths - mstallmo, issue/325 pull/328
-