Skip to content

Commit

Permalink
Chore build err (#434)
Browse files Browse the repository at this point in the history
* chore: rm needless fuzz code

* fix(wasm): build script fix

* chore: release info
  • Loading branch information
zxch3n authored Aug 27, 2024
1 parent 6333cf0 commit a761430
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 83 deletions.
6 changes: 6 additions & 0 deletions .changeset/sour-ladybugs-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"loro-wasm": patch
"loro-crdt": patch
---

Fix build script
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/loro-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ itertools = { workspace = true }
enum_dispatch = { workspace = true }
im = "15.1.0"
generic-btree = { version = "^0.10.5" }
getrandom = "0.2.10"
getrandom = "0.2.15"
once_cell = "1.18.0"
leb128 = "0.2.5"
num-traits = "0.2"
Expand Down
67 changes: 58 additions & 9 deletions crates/loro-internal/fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 0 additions & 40 deletions crates/loro-internal/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,8 @@ features = ["test_utils"]
[workspace]
members = ["."]

[[bin]]
name = "yata"
path = "fuzz_targets/yata.rs"
test = false
doc = false

# [profile.dev]
# lto = true
# opt-level = 3

[[bin]]
name = "text_refactored"
path = "fuzz_targets/text_refactored.rs"
test = false
doc = false

[[bin]]
name = "recursive_refactored"
path = "fuzz_targets/recursive_refactored.rs"
test = false
doc = false

[[bin]]
name = "import"
path = "fuzz_targets/import.rs"
test = false
doc = false

[[bin]]
name = "tree"
path = "fuzz_targets/tree.rs"
test = false
doc = false

[[bin]]
name = "richtext"
path = "fuzz_targets/richtext.rs"
test = false
doc = false

[[bin]]
name = "map"
path = "fuzz_targets/map.rs"
test = false
doc = false
8 changes: 0 additions & 8 deletions crates/loro-internal/fuzz/fuzz_targets/map.rs

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions crates/loro-internal/fuzz/fuzz_targets/richtext.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/loro-internal/fuzz/fuzz_targets/text_refactored.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/loro-internal/fuzz/fuzz_targets/tree.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/loro-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ wasm-bindgen = "=0.2.92"
serde-wasm-bindgen = { version = "^0.6.5" }
wasm-bindgen-derive = "0.2.1"
console_error_panic_hook = { version = "0.1.6", optional = true }
getrandom = { version = "0.2.10", features = ["js"] }
getrandom = { version = "0.2.15", features = ["js"] }
serde = { workspace = true }
rle = { path = "../rle", package = "loro-rle" }
tracing-wasm = "0.2.1"
Expand Down
14 changes: 14 additions & 0 deletions crates/loro-wasm/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ async function buildTarget(target: string) {
console.log(">", cmd);
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();
console.log();

if (target === "nodejs") {
console.log("🔨 Patching nodejs target");
const patch = await Deno.readTextFile(
path.resolve(__dirname, "./nodejs_patch.js"),
);
const wasm = await Deno.readTextFile(
path.resolve(targetDirPath, "loro_wasm.js"),
);
await Deno.writeTextFile(
path.resolve(targetDirPath, "loro_wasm.js"),
wasm + "\n" + patch,
);
}
}

build();
11 changes: 11 additions & 0 deletions crates/loro-wasm/scripts/nodejs_patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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
});
}

0 comments on commit a761430

Please sign in to comment.