Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support single-file executables via bun build --compile #318

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

Jarred-Sumner
Copy link
Contributor

This unblocks using tree-sitter-typescript in single-file executables

This is the same as tree-sitter/node-tree-sitter#230, except specifically for tree-sitter-typescript instead of tree-sitter.

node-gyp-build performs runtime checks for figuring out where the .node file is, but those runtime checks are difficult for static analysis to figure out where the .node file is. If we can rely on the prebuild to exist, we can use a template string and Bun will inline the process.platform, process.arch, and process.versions.bun fields within --compile.

Related PRs:

@amaanq
Copy link
Member

amaanq commented Nov 1, 2024

@Jarred-Sumner do you mind submitting a PR to update the template file pointed out here? This will allow anyone who creates a grammar automatically have the bun check

@Jarred-Sumner
Copy link
Contributor Author

@amaanq is there a way to know what the package name is statically? since node-gyp-build includes the package name in the file name

@amaanq
Copy link
Member

amaanq commented Nov 1, 2024

Yeah, when the bindings are initialized or updated there are few "variables" that are replaced with the parser's actual name, e.g. PARSER_NAME gets replaced with whatever the parser name is in the tree-sitter json config. So you could use this to update the template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants