Move tree-sitter-swift to optionalDependencies so npm doesn't abort
when its native build fails. The postinstall script now handles the
case where npm removes the package after a failed build by
re-installing with --ignore-scripts, then patching and rebuilding.
Also fixes JSON.parse crash on binding.gyp trailing commas and uses
createRequire for conditional imports in ESM context.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The script now detects missing native binding and runs node-gyp rebuild
after patching. This handles the case where tree-sitter-swift's own
postinstall fails during npm install — our postinstall picks up,
patches binding.gyp, and rebuilds successfully.