loro/crates/loro-wasm/scripts/nodejs_patch.js
Zixuan Chen a76143068a
Chore build err (#434)
* chore: rm needless fuzz code

* fix(wasm): build script fix

* chore: release info
2024-08-27 21:30:18 +08:00

11 lines
433 B
JavaScript

// Don't patch this if it already exists (for example in Deno)
if (!globalThis.crypto) {
// We need this patch because we use `getrandom` crate in Rust, which relies on this patch
// for nodejs
// https://docs.rs/getrandom/latest/getrandom/#nodejs-es-module-support
const { webcrypto } = require("crypto");
Object.defineProperty(globalThis, 'crypto', {
value: webcrypto,
writable: true
});
}