From 98b9bee876eabfc47eeed8364e565a2cf69d6c63 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Mar 2018 20:32:48 -0800 Subject: [PATCH] Add some comments to the hello-world example --- examples/hello_world/build.sh | 6 ++++++ examples/hello_world/index.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/examples/hello_world/build.sh b/examples/hello_world/build.sh index 89faf5e87..770873c50 100755 --- a/examples/hello_world/build.sh +++ b/examples/hello_world/build.sh @@ -2,8 +2,12 @@ set -ex +# Build the `hello_world.wasm` file using Cargo/rustc cargo +nightly build --target wasm32-unknown-unknown --release +# Run the `wasm-bindgen` CLI tool to postprocess the wasm file emitted by the +# Rust compiler to emit the JS support glue that's necessary +# # Here we're using the version of the CLI in this repository, but for external # usage you'd use the commented out version below cargo +nightly run --manifest-path ../../crates/wasm-bindgen-cli/Cargo.toml \ @@ -11,5 +15,7 @@ cargo +nightly run --manifest-path ../../crates/wasm-bindgen-cli/Cargo.toml \ ../../target/wasm32-unknown-unknown/release/hello_world.wasm --out-dir . # wasm-bindgen ../../target/wasm32-unknown-unknown/hello_world.wasm --out-dir . +# Finally, package everything up using Webpack and start a server so we can +# browse the result npm install npm run serve diff --git a/examples/hello_world/index.js b/examples/hello_world/index.js index 32c38c7fe..9173576c9 100644 --- a/examples/hello_world/index.js +++ b/examples/hello_world/index.js @@ -1,3 +1,6 @@ +// Note that a dynamic `import` statement here is required due to +// webpack/webpack#6615, but in theory `import { greet } from './hello_world';` +// will work here one day as well! const js = import("./hello_world"); js.then(js => {