abianche/skroll

Support native tree-sitter-skroll bindings in Electron builds

Open

#78 aperta il 29 set 2025

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)TypeScript (0 fork)auto 404
featureffihelp wanted

Metriche repository

Star
 (0 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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.

Guida contributor