Removed instantiatestreaming hack

master
DavidOConnor 6 years ago
parent dae1e76e35
commit 02d535282a

@ -9,7 +9,7 @@ edition = "2018"
crate-type = ["cdylib"]
[dependencies]
seed = "^0.1.2"
seed = "^0.1.4"
wasm-bindgen = "^0.2.29"
web-sys = "^0.3.6"

@ -3,7 +3,7 @@
**To get started:**
- Clone this repo
- If you don't have Rust and wasm-bindgen installed, [Download it](https://www.rust-lang.org), and run the following commands:
- If you don't have Rust and wasm-bindgen installed, [Download it](https://www.rust-lang.org/tools/install), and run the following commands:
`rustup update`
@ -11,7 +11,9 @@
`cargo install wasm-bindgen-cli`
- Run `build.sh` or `build.ps1`, then open `index.html` in a web browser, or use a local server. (Opening the file directly may not work in some browsers.)
- Run `build.sh` or `build.ps1`, then then start a dev server that supports WASM.
For example, with [Python](https://www.python.org/downloads/) installed, run `python server.py`.
(Linux users may need to run `python3 server.py`.)
Once you rename the crate in `Cargo.toml` (The `name` field under `[Package]`), make the
following changes:

@ -16,19 +16,6 @@
<body>
<section id="main"></section>
<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
// but this doesn't work with `file://` urls. This example is frequently
// viewed by simply opening `index.html` in a browser (with a `file://`
// url), so it would fail if we were to call this function!
//
// Work around this for now by deleting the function to ensure that the
// `no_modules.js` script doesn't have access to it. You won't need this
// hack when deploying over HTTP.
delete WebAssembly.instantiateStreaming;
</script>
<script src='./pkg/appname.js'></script>
<script>

@ -0,0 +1,19 @@
#!/usr/bin/env python3
# From https://gist.github.com/prideout/09af26cef84eef3e06a1e3f20a499a48
import http.server
import socketserver
PORT = 8000
handler = http.server.SimpleHTTPRequestHandler
handler.extensions_map.update({
'.wasm': 'application/wasm',
})
socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(("", PORT), handler) as httpd:
httpd.allow_reuse_address = True
print("Serving at port", PORT)
httpd.serve_forever()

@ -38,7 +38,7 @@ fn update(msg: Msg, model: Model) -> Model {
fn view(model: Model) -> El<Msg> {
button![
vec![simple_ev("click", Msg::Increment)],
simple_ev("click", Msg::Increment),
format!("Hello, World × {}", model.val)
]
}

Loading…
Cancel
Save