feat(web)!: use the WASM module in the bindings, and not the other way around

Parser is no longer the default export, but you *must* call
`Parser.init()` before doing anything still
This commit is contained in:
Amaan Qureshi 2025-01-19 15:15:01 -05:00
parent b1e39d2dba
commit be7716dfa7
29 changed files with 613 additions and 662 deletions

View file

@ -0,0 +1,14 @@
import createModule, { type MainModule } from '../lib/tree-sitter';
export let Module: MainModule | null = null;
export async function initializeBinding(moduleOptions: EmscriptenModule): Promise<MainModule> {
if (!Module) {
Module = await createModule(moduleOptions);
}
return Module;
}
export function checkModule(): boolean {
return !!Module;
}