-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle conditional loading of js wasm
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// https://stackoverflow.com/a/47880734 | ||
const supported = (() => { | ||
try { | ||
if (typeof WebAssembly === "object" | ||
&& typeof WebAssembly.instantiate === "function") { | ||
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)); | ||
if (module instanceof WebAssembly.Module) | ||
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance; | ||
} | ||
} catch (e) { | ||
} | ||
return false; | ||
})(); | ||
|
||
let wasm; | ||
|
||
if (supported) { | ||
wasm = await import('./bitwarden_wasm_bg.wasm'); | ||
} else { | ||
wasm = await import('./bitwarden_wasm_bg.wasm.js'); | ||
} | ||
|
||
import { __wbg_set_wasm } from "./bitwarden_wasm_bg.js"; | ||
__wbg_set_wasm(wasm); | ||
export * from "./bitwarden_wasm_bg.js"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters