mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-02 22:21:33 +00:00
Switch the --browser
argument to --web
This commit reverts part of the implementation of [RFC 6]. That RFC specified that the `--browser` flag was going to be repurposed for the new "natively loadable as ES module output", but unfortunately the breakage is far broader than initially expected. It turns out that `wasm-pack` passes `--browser` by default which means that a change to break `--browser` would break all historical versions of `wasm-pack` which is a bit much for now. To solve this the `--browser` flag is going back to what it represents on the current released version of `wasm-bindgen` (optimize away some node.js checks in a few places for bundler-style output) and a new `--web` flag is being introduced as the new deployment strategy. [RFC 6]: https://github.com/rustwasm/rfcs/pull/6 Closes #1318
This commit is contained in:
@ -14,8 +14,8 @@ and then opening `index.html` in a browser should run the example!
|
||||
|
||||
Note that this example is in contrast to the [without a bundler][wab] example
|
||||
which performs a similar purpose except it uses `--no-modules` instead of
|
||||
`--browser`. The main difference here is how the shim JS and module are loaded,
|
||||
where this example uses old-school `script` tags while `--browser` uses ES
|
||||
`--web`. The main difference here is how the shim JS and module are loaded,
|
||||
where this example uses old-school `script` tags while `--web` uses ES
|
||||
modules.
|
||||
|
||||
[wab]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/without-a-bundler
|
||||
|
@ -7,8 +7,8 @@
|
||||
<script src='pkg/without_a_bundler_no_modules.js'></script>
|
||||
|
||||
<script type=module>
|
||||
// Like with the `--browser` output the exports are immediately available
|
||||
// but they won't work until we initialize the module. Unlike `--browser`,
|
||||
// Like with the `--web` output the exports are immediately available
|
||||
// but they won't work until we initialize the module. Unlike `--web`,
|
||||
// however, the globals are all stored on a `wasm_bindgen` global. The
|
||||
// global itself is the initialization function and then the properties of
|
||||
// the global are all the exported functions.
|
||||
|
@ -11,7 +11,7 @@ $ cargo build --target wasm32-unknown-unknown --release
|
||||
$ cargo run -p wasm-bindgen-cli --bin wasm-bindgen -- \
|
||||
../../target/wasm32-unknown-unknown/release/without_a_bundler.wasm \
|
||||
--out-dir pkg \
|
||||
--browser
|
||||
--web
|
||||
```
|
||||
|
||||
and then opening `index.html` in a browser should run the example!
|
||||
|
@ -3,13 +3,13 @@
|
||||
set -ex
|
||||
|
||||
# Note that typically we'd use `wasm-pack` to build the crate, but the
|
||||
# `--browser` flag is very new to `wasm-bindgen` and as such doesn't have
|
||||
# `--web` flag is very new to `wasm-bindgen` and as such doesn't have
|
||||
# support in `wasm-pack` yet. Support will be added soon though!
|
||||
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
cargo run --manifest-path ../../crates/cli/Cargo.toml \
|
||||
--bin wasm-bindgen -- \
|
||||
../../target/wasm32-unknown-unknown/release/without_a_bundler.wasm --out-dir pkg \
|
||||
--browser
|
||||
--web
|
||||
|
||||
python3 -m http.server
|
||||
|
Reference in New Issue
Block a user