bennyp
bennyp2w ago

deno compile --include whatev.wasm

I'd like to include a wasm file as data, but when I try to --include it I get
error: Relative import path "env" not prefixed with / or ./ or ../ and not in import map from "file:///var/home/bennyp/Developer/design-tokens-language-server/src/server/css/tree-sitter/tree-sitter-css.wasm"
error: Relative import path "env" not prefixed with / or ./ or ../ and not in import map from "file:///var/home/bennyp/Developer/design-tokens-language-server/src/server/css/tree-sitter/tree-sitter-css.wasm"
I'm aware that the docs say to add wasm imports to the import map, but that's not what I'm getting at: I just want to include a tree sitter grammar as data so that web-tree-sitter can load it up.
1 Reply
bennyp
bennypOP2w ago
Basically I'm trying to get the old wasm importing behaviour, without all the static analysis:
import { Parser, Language, Query } from "web-tree-sitter";
import { readAll } from 'jsr:@std/io/read-all';

const f = await Deno.open("./tree-sitter/tree-sitter-css.wasm")
const grammar = await readAll(f);

await Parser.init();
const parser = new Parser();
const Css = await Language.load(grammar);
parser.setLanguage(Css);
import { Parser, Language, Query } from "web-tree-sitter";
import { readAll } from 'jsr:@std/io/read-all';

const f = await Deno.open("./tree-sitter/tree-sitter-css.wasm")
const grammar = await readAll(f);

await Parser.init();
const parser = new Parser();
const Css = await Language.load(grammar);
parser.setLanguage(Css);

Did you find this page helpful?