Skip to content

Commit d7f4e67

Browse files
committed
sdk: dynamically fetch __dirname in init-node
1 parent 78c3e70 commit d7f4e67

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { fileURLToPath } from 'url'
55

66
/**
77
* Helper function to get the current directory path that works in both ESM and CJS
8+
* Uses dynamic evaluation to prevent bundlers from inlining absolute paths
89
*/
910
function hereDir() {
10-
// In CJS, __dirname is available
11+
// In CJS, __dirname is available - use indirect eval to prevent inlining
1112
if (typeof __dirname !== 'undefined') {
12-
return __dirname
13+
// Use a trick to get __dirname dynamically without bundler inlining it
14+
// This works because bundlers won't inline values from Function constructor
15+
return new Function('return __dirname')()
1316
}
1417

1518
// For ESM builds, use import.meta.url

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codebuff/sdk",
33
"private": false,
4-
"version": "0.3.7",
4+
"version": "0.3.8",
55
"description": "Official SDK for Codebuff — AI coding agent & framework",
66
"license": "Apache-2.0",
77
"type": "module",

0 commit comments

Comments
 (0)