mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-11 14:53:12 +00:00
chore: speedup wasm build
This commit is contained in:
parent
b0d7ad88b9
commit
85d91e10b4
1 changed files with 24 additions and 13 deletions
|
@ -32,6 +32,26 @@ async function build() {
|
||||||
return buildTarget(target);
|
return buildTarget(target);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (profile !== "dev") {
|
||||||
|
let first = true;
|
||||||
|
let firstTarget = "";
|
||||||
|
for (const target of TARGETS) {
|
||||||
|
if (first) {
|
||||||
|
const cmd =
|
||||||
|
`wasm-opt -O4 ${target}/loro_wasm_bg.wasm -o ${target}/loro_wasm_bg.wasm`;
|
||||||
|
console.log(">", cmd);
|
||||||
|
firstTarget = target;
|
||||||
|
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
const cmd =
|
||||||
|
`cp ${firstTarget}/loro_wasm_bg.wasm ${target}/loro_wasm_bg.wasm`;
|
||||||
|
console.log(">", cmd);
|
||||||
|
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
"✅",
|
"✅",
|
||||||
"Build complete in",
|
"Build complete in",
|
||||||
|
@ -67,20 +87,11 @@ async function buildTarget(target: string) {
|
||||||
console.log("Clear directory " + targetDirPath);
|
console.log("Clear directory " + targetDirPath);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
for (const cmd of genCommands(target)) {
|
const cmd =
|
||||||
|
`wasm-bindgen --weak-refs --target ${target} --out-dir ${target} ../../target/wasm32-unknown-unknown/${profileDir}/loro_wasm.wasm`;
|
||||||
console.log(">", cmd);
|
console.log(">", cmd);
|
||||||
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();
|
await Deno.run({ cmd: cmd.split(" "), cwd: LoroWasmDir }).status();
|
||||||
}
|
|
||||||
console.log();
|
console.log();
|
||||||
}
|
}
|
||||||
|
|
||||||
function genCommands(target: string): string[] {
|
|
||||||
return [
|
|
||||||
`wasm-bindgen --weak-refs --target ${target} --out-dir ${target} ../../target/wasm32-unknown-unknown/${profileDir}/loro_wasm.wasm`,
|
|
||||||
...(profile == "dev" ? [] : [
|
|
||||||
`wasm-opt -O4 ${target}/loro_wasm_bg.wasm -o ${target}/loro_wasm_bg.wasm`,
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
build();
|
build();
|
||||||
|
|
Loading…
Reference in a new issue