Skip to content

Fix the wasm2js example #1750

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

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/wasm2js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ $ ./build.sh

(or running the commands on Windows manually)

and then visiting http://localhost:8080 in a browser should run the example!
and then visiting http://localhost:8000 in a browser should run the example!
9 changes: 4 additions & 5 deletions examples/wasm2js/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
set -ex

# Compile our wasm module and run `wasm-bindgen`
wasm-pack build
wasm-pack build --target web

# Run the `wasm2js` tool from `binaryen`
wasm2js pkg/wasm2js_bg.wasm -o pkg/wasm2js_bg.js

# Move our original wasm out of the way to avoid cofusing Webpack.
mv pkg/wasm2js_bg.wasm pkg/wasm2js_bg.bak.wasm
# Update our JS shim to require the JS file instead
sed -i 's/wasm2js_bg.wasm/wasm2js_bg.js/' pkg/wasm2js.js

npm install
npm run serve
http
1 change: 1 addition & 0 deletions examples/wasm2js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<body>
<p>Open up the developer console to see "Hello, World!"</p>
</body>
<script src=index.js type=module></script>
</html>
8 changes: 4 additions & 4 deletions examples/wasm2js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Note that since we're not using `WebAssembly` we can do a synchronous import
// here!
import { run } from './pkg/wasm2js';
run();
// Import our JS shim and initialize it, executing the start function when it's
// ready.
import init from './pkg/wasm2js.js';
init();
13 changes: 0 additions & 13 deletions examples/wasm2js/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/wasm2js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern "C" {
fn log(s: &str);
}

#[wasm_bindgen]
#[wasm_bindgen(start)]
pub fn run() {
log("Hello, World!");
}
23 changes: 0 additions & 23 deletions examples/wasm2js/webpack.config.js

This file was deleted.