From e7450e21e189906a9661e57fed6682abb47e5600 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Sat, 16 Nov 2024 19:30:37 +0800 Subject: [PATCH] chore: fix build script --- crates/loro-wasm/scripts/post-rollup.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/loro-wasm/scripts/post-rollup.ts b/crates/loro-wasm/scripts/post-rollup.ts index 6691965b..5304a22e 100644 --- a/crates/loro-wasm/scripts/post-rollup.ts +++ b/crates/loro-wasm/scripts/post-rollup.ts @@ -71,15 +71,10 @@ async function rollupBase64() { console.error("Failed to execute rollup command:", error); } - const toReplaceFrom = `{ - const wkmod = await import('./loro_wasm_bg-b2849b85.js'); - const instance = new WebAssembly.Instance(wkmod.default, { - "./loro_wasm_bg.js": imports, - }); - __wbg_set_wasm(instance.exports); -}`; + const toReplaceFrom = + /\{\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-b2849b85.js'; +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, }); @@ -87,7 +82,7 @@ __wbg_set_wasm(instance.exports); `; const base64IndexPath = "./base64/index.js"; const content = await Deno.readTextFile(base64IndexPath); - if (!content.includes(toReplaceFrom)) { + if (!content.match(toReplaceFrom)) { throw new Error( `Could not find string to replace in ${base64IndexPath}`, );