mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-15 04:23:12 +03:00
995be7c027
This commit deprecates the `--web`, `--no-modules`, and `--nodejs` flags in favor of one `--target` flag. The motivation for this commit is to be consistent between `wasm-bindgen` and `wasm-pack` so documentation for one is applicable for the other (so we don't have to document everywhere what the translation is between flags). Additionally this should make it a bit easier to add new targets (if necessary) in the future as it won't add to the proliferation of flags. For now the old flags (like `--web`) continue to be accepted, but they'll be removed during the next set of breaking changes for `wasm-bindgen`.
32 lines
1.0 KiB
HTML
32 lines
1.0 KiB
HTML
<html>
|
|
<head>
|
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
|
|
</head>
|
|
<body>
|
|
<!-- Include the JS generated by `wasm-pack build` -->
|
|
<script src='pkg/without_a_bundler_no_modules.js'></script>
|
|
|
|
<script type=module>
|
|
// Like with the `--target web` output the exports are immediately
|
|
// available but they won't work until we initialize the module. Unlike
|
|
// `--target 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.
|
|
//
|
|
// Note that the name `wasm_bindgen` can be configured with the
|
|
// `--no-modules-global` CLI flag
|
|
const { add } = wasm_bindgen;
|
|
|
|
async function run() {
|
|
await wasm_bindgen('./pkg/without_a_bundler_no_modules_bg.wasm');
|
|
|
|
const result = add(1, 2);
|
|
console.log(`1 + 2 = ${result}`);
|
|
}
|
|
|
|
run();
|
|
</script>
|
|
</body>
|
|
</html>
|