Skip to content

Commit 4f3446b

Browse files
committed
remove checking for __dirname entirely for tree-sitter.wasm
1 parent dfa5a91 commit 4f3446b

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

packages/code-map/src/init-node.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import { fileURLToPath } from 'url'
43

54
import { Parser } from 'web-tree-sitter'
65

7-
import { getDirnameDynamically } from './utils'
8-
9-
/**
10-
* Helper function to get the current directory path that works in both ESM and CJS
11-
* Uses runtime-only approach to prevent bundlers from inlining absolute paths
12-
*/
13-
function hereDir() {
14-
const dirname = getDirnameDynamically()
15-
if (typeof dirname !== 'undefined') {
16-
return dirname
17-
}
18-
19-
// For ESM builds, use import.meta.url
20-
if (typeof import.meta !== 'undefined' && import.meta.url) {
21-
const dir = path.dirname(fileURLToPath(import.meta.url))
22-
return dir
23-
}
24-
25-
// Fallback to process.cwd() as last resort
26-
return process.cwd()
27-
}
28-
296
/**
307
* Initialize web-tree-sitter for Node.js environments with proper WASM file location
318
*/
329
export async function initTreeSitterForNode(): Promise<void> {
33-
// Get the directory where our WASM files should be located
34-
const dir = hereDir()
35-
36-
// Try shared WASM directory first (new approach to avoid duplication)
37-
const sharedWasm = path.join(dir, '..', 'wasm', 'tree-sitter.wasm')
38-
3910
// Use locateFile to override where the runtime looks for tree-sitter.wasm
4011
await Parser.init({
4112
locateFile: (name: string, scriptDir: string) => {
4213
if (name === 'tree-sitter.wasm') {
43-
// First try shared WASM directory (new approach)
44-
if (fs.existsSync(sharedWasm)) {
45-
return sharedWasm
46-
}
4714
// Fallback to script directory
4815
const fallback = path.join(scriptDir, name)
4916
if (fs.existsSync(fallback)) {

0 commit comments

Comments
 (0)