mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-05-31 06:31:22 +00:00
31 lines
1017 B
HTML
31 lines
1017 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 type=module>
|
||
|
// Like with the `--browser` output the exports are immediately available
|
||
|
// but they won't work until we initialize the module. Unlike `--browser`,
|
||
|
// 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>
|