tree-sitter-cmake icon indicating copy to clipboard operation
tree-sitter-cmake copied to clipboard

WIP: build: migrate to wasm-based build and add smoke tests

Open svjson opened this issue 2 months ago • 0 comments

WHAT

  • Migrated node/npm package to wasm-only build
  • Added separate entrypoints for esm and cjs
  • Added smoke tests for the npm package, verifying that the grammar can be loaded and used both as ESM module and CommonJS

WHY DROP THE NODE-GYP BUILD?

EDIT: Actually I may have done goofed here - it seems like there IS an ongoing effort: https://github.com/tree-sitter/node-tree-sitter/pull/258

I also linked to the wrong issues below. I'll fix this + watch the situation with the tree-sitter-node situation and revert to the dual gyp/wasm builds if the above PR gets accepted.


The tree-sitter package doesn't support grammars built with tree-sitter >= 0.25 and is no longer being updated to support recent ABI changes.

The upstream maintainers have effectively deprecated native bindings in favor of WebAssembly builds (web-tree-sitter), which are portable, easier to distribute, and doesn’t require native compilation or prebuild infrastructure.

As of Tree-sitter 0.25, grammars generated by the official CLI are ABI-incompatible with the older Node C API used by node-tree-sitter a k a tree-sitter

I initially fiddled with separate builds and packages, tree-sitter-cmake-wasm and tree-sitter-cmake-gyp but abandoned this as there is no tree-sitter release capable of loading the native grammar, rendering a gyp build effectively useless.

WHAT'S NOT INCLUDED?

  • Github Actions Workflows have not been updated to build, test or publish the npm artifact yet. This will be a separate PR.
  • The binding test in bindings/node still works as parser.setLanguage(...) doesn't validate the grammar. The errors due to incompatibility does not show up until a parsed Tree object is interacted with. As far as I know, bindings/node no longer serves a purpose, but I'm not familiar enough with the setup and workings of tree-sitter grammar projects to be bold enough to go ahead and delete it. Yet.

svjson avatar Oct 11 '25 23:10 svjson