fix(core): use workaround for wasm loading
This commit is contained in:
parent
14549020aa
commit
f274dfe857
2 changed files with 12 additions and 1 deletions
|
@ -2,6 +2,15 @@ import { MtcuteWasmModule, SyncInitInput } from './types.js'
|
|||
|
||||
export * from './types.js'
|
||||
|
||||
export function getWasmUrl(): URL {
|
||||
// would be nice if we could just use `new URL('@mtcute/wasm/mtcute.wasm', import.meta.url)`
|
||||
// wherever this is used, but vite does some funky stuff with transitive dependencies
|
||||
// making it not work. probably related to https://github.com/vitejs/vite/issues/8427,
|
||||
// but asking the user to deoptimize the entire @mtcute/web is definitely not a good idea
|
||||
// so we'll just use this hack for now
|
||||
return new URL('../mtcute.wasm', import.meta.url)
|
||||
}
|
||||
|
||||
let wasm!: MtcuteWasmModule
|
||||
let compressor!: number
|
||||
let decompressor!: number
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { getWasmUrl } from '@mtcute/wasm'
|
||||
|
||||
export type WasmInitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module
|
||||
|
||||
export async function loadWasmBinary(input?: WasmInitInput): Promise<WebAssembly.Instance> {
|
||||
if (typeof input === 'undefined') {
|
||||
input = new URL('@mtcute/wasm/mtcute.wasm', import.meta.url)
|
||||
input = getWasmUrl()
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue