The first page of the "Beginner" section ends with this sidebar:
If you intend to use your WASM module in a plain HTML website, you'll need to tell wasm-pack to target the web...
In my mind, the most straightforward thing to do with those instructions was to save the example HTML to a local tutorial1_window.html file and directly open it in a browser. That didn't work. Turns out cross-origin restrictions prevent importing ./pkg/tutorial1_window.js when using the file:// protocol.
For some programming backgrounds, it may be a very obvious assumption that "Of course I have already a full web development toolchain set up, which will obviously include a web server serving local static pages, as well as (this thing), (that thing), and (some other thing)".
On the other hand, this is a "Beginner" page, and Rust is primarily a native-code systems-programming language. It's reasonable that some Rust programmers will begin from a background that lacks that assumption.
python -m http.server and http://localhost:8000/tutorial1_window.html was easy once I figured out what the missing piece was. But it took quite some time to figure out what the missing piece was.
The first page of the "Beginner" section ends with this sidebar:
In my mind, the most straightforward thing to do with those instructions was to save the example HTML to a local
tutorial1_window.htmlfile and directly open it in a browser. That didn't work. Turns out cross-origin restrictions prevent importing./pkg/tutorial1_window.jswhen using thefile://protocol.For some programming backgrounds, it may be a very obvious assumption that "Of course I have already a full web development toolchain set up, which will obviously include a web server serving local static pages, as well as (this thing), (that thing), and (some other thing)".
On the other hand, this is a "Beginner" page, and Rust is primarily a native-code systems-programming language. It's reasonable that some Rust programmers will begin from a background that lacks that assumption.
python -m http.serverandhttp://localhost:8000/tutorial1_window.htmlwas easy once I figured out what the missing piece was. But it took quite some time to figure out what the missing piece was.