abianche/skroll

Support native tree-sitter-skroll bindings in Electron builds

Open

#78 geöffnet am 29. Sept. 2025

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (0 Forks)auto 404
featureffihelp wanted

Repository-Metriken

Stars
 (0 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Description

Currently Skroll uses the WASM grammar (web-tree-sitter) to avoid ABI and packaging issues. If we ever want to switch back to native bindings for performance reasons, the following work is needed:

  • Add a webpack rule to relocate the native .node binary from the workspace package into .webpack/main/native_modules:
{
  test: /@skroll[\\/]tree-sitter-skroll[\\/].+\.(m?js|node)$/,
  parser: { amd: false },
  use: {
    loader: '@vercel/webpack-asset-relocator-loader',
    options: { outputAssetBase: 'native_modules' },
  },
}
  • Update forge.config.ts to unpack native files:
packagerConfig: {
  asar: { unpack: "{**/*.node,**/native_modules/**/*}" },
}
  • Ensure electron-rebuild runs after install so the binary matches the current Electron ABI:
{ "scripts": { "postinstall": "electron-rebuild -f -w tree-sitter -w @skroll/tree-sitter-skroll" } }
  • Import the binding via node-gyp-build at runtime (avoid bundling it).

Notes

  • Without these steps, Electron will throw "No native build was found for … abi=XXX" when loading the parser.

WASM path is stable; native path is only worth it if profiling shows parsing speed as a bottleneck.

Contributor Guide