mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-15 09:40:52 +00:00
32 lines
1020 B
HTML
32 lines
1020 B
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>
|
|
// 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>
|