Open khromov opened 5 days ago
Managed to work around the import issue by manually getting the requires import urls via Vites ?url
modifier and pass them to corePath
/wasmPath
:
onMount(async () => {
try {
const ftImport = await import('fasttext.wasm');
const corePath = await import('fasttext.wasm/dist/core/fasttext.mjs?url');
const wasmPath = await import('fasttext.wasm/dist/core/fasttext.wasm?url');
const modelPath = await import('./model_cooking.ftz?url');
fastText = await ftImport.FastText.create({
corePath: corePath.default,
wasmPath: wasmPath.default,
});
await fastText.loadModel(modelPath.default);
loading = false;
} catch (error) {
console.error('Error loading FastText model:', error);
modelError = 'Failed to load the FastText model. Please check the console for more details.';
loading = false;
}
});
đ I'm trying to use this library in a Vite / SvelteKit application, but I'm having a similar issue to #1
I'm getting:
Reproduction: https://www.sveltelab.dev/zez8tfh1obg0kjv
I also tried doing it client side only with
const ftImport = await import('fasttext.wasm');
inside onMount > try, then callingconst fastText = await ftImport.FastText.create()
but got the same error, just client side instead:Code: