oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.21k stars 2.77k forks source link

Bun is not building the tree-sitter language package #7518

Open m-paternostro opened 11 months ago

m-paternostro commented 11 months ago

What version of Bun is running?

1.0.15

What platform is your computer?

Darwin 23.1.0 x86_64 i386

What steps can reproduce the bug?

The easiest way to reproduce this issue is to run bun i with the following package.json

{
  "name": "mycoolproject",
  "module": "index.ts",
  "type": "module",
  "scripts": {
    "start": "bun run index.ts"
  },
  "trustedDependencies": [
    "tree-sitter",
    "tree-sitter-java"
  ],
  "dependencies": {
    "tree-sitter": "^0.20.6",
    "tree-sitter-java": "^0.20.2"
  },
  "peerDependencies": {
    "typescript": "^5.3.2"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^6.13.2",
    "@typescript-eslint/parser": "^6.13.2",
    "bun-types": "^1.0.15",
    "eslint-config-prettier": "^9.1.0",
    "eslint-import-resolver-typescript": "^3.6.1",
    "eslint-import-resolver-typescript-bun": "^0.0.66",
    "eslint-plugin-import": "^2.29.0",
    "eslint-plugin-simple-import-sort": "^10.0.0",
    "prettier": "^3.1.0"
  }
}

What is the expected behavior?

Using npm i, the tree-sitter-java module is built and then everything works. More precisely, after the installation with npm, the directory node_modules/tree-sitter-java/build is available.

What do you see instead?

After installing the dependencies with bun i, the node_modules/tree-sitter-java/build is not available, which seems to indicate that the installation has not triggered this module to be built (as it happens with npm). Notice that I have added both modules as trustedDependencies

As a result, the tests that pass with npm fail in bun:

❯ bun test     
bun test v1.0.15 (b3bdf22e)

lib/tests/languages/java/import.test.ts:
error: Cannot find module "../../build/Release/tree_sitter_java_binding" from "/Users/me/mycoolproject/codegraph2/node_modules/tree-sitter-java/bindings/node/index.js"

 0 pass
 1 fail
Ran 1 tests across 1 files. [23.00ms]

Additional information

No response

amaanq commented 9 months ago

doesn't feel like a bun issue, did you actually build the binding with bun install or something like that? The tree_sitter_java_binding is built by node-gyp so you could also just run node-gyp build

di-sukharev commented 2 months ago

how do you even run this?

when i import tree-sitter bindings and run them in bun context i get this

nicolasembleton commented 1 month ago

how do you even run this?

when i import tree-sitter bindings and run them in bun context i get this

Yes, I have the same problem. I hope the missing flag gets implemented soon. Would love to get tree-sitter working on Bun. Still need to rely on NodeJS for that specific one.