Skip to content

Commit

Permalink
chore: fix build script
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Nov 16, 2024
1 parent 70c4942 commit e7450e2
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions crates/loro-wasm/scripts/post-rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,18 @@ 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,
});
__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}`,
);
Expand Down

0 comments on commit e7450e2

Please sign in to comment.