abianche/skroll

Support native tree-sitter-skroll bindings in Electron builds

Open

#78 创建于 2025年9月29日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)TypeScript (0 fork)auto 404
featureffihelp wanted

仓库指标

Star
 (0 star)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南