Sync the vendored grammar + WASM + queries from the published
tree-sitter-mf2
npm package.
This package embeds the MF2 grammar as browser-facing artefacts:
WASM (
priv/static/tree-sitter-mf2.wasm) — what theweb-tree-sitterruntime actually loads.Queries (
priv/static/highlights.scm) — fetched at runtime by the JS hook.Grammar source (
priv/grammar/) — parser.c, parser.h, grammar.json, node-types.json, grammar.js. Kept alongside so the WASM can be regenerated locally with--build-wasm.
The canonical source is the npm package, pinned to an exact
version at the top of this module (@tree_sitter_mf2_version).
Bump that string and re-run the task to move to a new grammar
release. Keep the pin in step with localize_mf2_treesitter's
own sync task — tree shape is the API boundary between
server-side parse (NIF) and browser-side parse (WASM editor); a
version skew can produce different trees for the same input.
Usage
# Fetch from npm at the pinned version and update local files.
mix mf2_wasm_editor.sync
# Fail (exit 1) if anything has drifted from the pinned
# version; do not modify files. Intended for CI.
mix mf2_wasm_editor.sync --check
# Additionally rebuild priv/static/tree-sitter-mf2.wasm from
# the vendored grammar instead of using the prebuilt .wasm
# shipped in the npm tarball. Requires a local `mf2_treesitter`
# checkout (via MF2_TREESITTER_DIR) with `npm install` already
# run, plus emcc / docker / podman on PATH.
mix mf2_wasm_editor.sync --build-wasmOffline / local-iteration override
If you're iterating on the grammar locally and want this task to
read from a sibling checkout rather than hit the network, set
MF2_TREESITTER_DIR:
MF2_TREESITTER_DIR=/path/to/mf2_treesitter mix mf2_wasm_editor.syncWith that set, file layouts must match the npm package layout
(which also matches the repo layout): grammar.js at the root,
src/parser.c, queries/highlights.scm, wasm/tree-sitter-mf2.wasm.