-
Sorry for stupid question, but i tried to import this package into my vue component but it doesn't work |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Maybe use |
Beta Was this translation helpful? Give feedback.
-
Added this code and it works now: |
Beta Was this translation helpful? Give feedback.
-
I had the same issue and resorted to copying the files into the public directory. But I think I figured out a more clean solution, but only works in Chrome! We can use the Vite import { init } from "z3-solver/build/low-level";
import initZ3 from "z3-solver/build/z3-built";
let z3 = init(async () => {
const files = {
"z3-built.js": await import("z3-solver/build/z3-built?url"),
"z3-built.wasm": await import("z3-solver/build/z3-built.wasm?url"),
"z3-built.worker.js": await import("z3-solver/build/z3-built.worker?url"),
};
return initZ3({
locateFile: (f) => {
if (!(f in files)) throw new Error(`unknown z3 file: ${f}`);
return files[f as keyof typeof files].default;
},
mainScriptUrlOrBlob: files["z3-built.js"].default,
});
}); This works for the low-level API, but I've yet to get it to work with the high-level. One thing still missing, is that browsers might prevent service workers from being loaded over an insecure channel or due to CORS in general, and thus you need to have coi-serviceworker setup as well for localhost. As a side-note for how this could be improved, import * as wasm from './wasm_bg.wasm'; To get this to work, you need the |
Beta Was this translation helpful? Give feedback.
Added this code and it works now:
var tag = document.createElement("script"); tag.src = "/node_modules/z3-solver/build/z3-built.js"; document.getElementsByTagName("head")[0].appendChild(tag);