abianche/skroll

Support native tree-sitter-skroll bindings in Electron builds

Open

#78 opened on Sep 29, 2025

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (0 forks)auto 404
featureffihelp wanted

Repository metrics

Stars
 (0 stars)
PR merge metrics
 (PR metrics pending)

Description

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