chore: fix base64 build in cloudflare worker

This commit is contained in:
Zixuan Chen 2024-11-16 20:11:05 +08:00
parent c4a9729c9c
commit 3f34a9eb71
No known key found for this signature in database
3 changed files with 16 additions and 5 deletions

View file

@ -1,5 +1,11 @@
# Changelog
## 1.1.3-alpha.0
### Patch Changes
- Chore fix base64 built target in cloudflare worker
## 1.1.2
### Patch Changes

View file

@ -1,6 +1,6 @@
{
"name": "loro-crdt",
"version": "1.1.2",
"version": "1.1.3-alpha.0",
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
"keywords": [
"crdt",

View file

@ -75,10 +75,15 @@ async function rollupBase64() {
/\{\s*const wkmod = await import\('\.\/loro_wasm_bg-([^']+)\.js'\);\s*const instance = new WebAssembly\.Instance\(wkmod\.default, \{\s*"\.\/loro_wasm_bg\.js": imports,\s*\}\);\s*__wbg_set_wasm\(instance\.exports\);\s*\}/;
const toReplaceTarget = `
import loro_wasm_bg_js from './loro_wasm_bg-$1.js';
const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
"./loro_wasm_bg.js": imports,
});
__wbg_set_wasm(instance.exports);
if (wasm.__wbindgen_start) {
imports.__wbg_set_wasm(loro_wasm_bg_js());
wasm.__wbindgen_start();
} else {
const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
"./loro_wasm_bg.js": imports,
});
__wbg_set_wasm(instance.exports);
}
`;
const base64IndexPath = "./base64/index.js";
const content = await Deno.readTextFile(base64IndexPath);