Skip to content

Commit 49bc547

Browse files
authored
feat: Use fs.readFileSync to load package.json for Node 19 compat (#76)
* feat: Use fs.readFileSync to load package.json for Node 19 compat * tsconfig
1 parent 7b0a981 commit 49bc547

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

browserbase/src/program.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { program } from 'commander';
2+
import * as fs from 'fs';
3+
import * as path from 'path';
4+
import { fileURLToPath } from 'url';
25

36
import { createServer } from './index.js';
47
import { ServerList } from './server.js';
@@ -7,7 +10,14 @@ import { startHttpTransport, startStdioTransport } from './transport.js';
710

811
import { resolveConfig } from './config.js';
912

10-
import packageJSON from '../package.json' with { type: 'json' };
13+
// Determine the directory of the current module
14+
const __filename = fileURLToPath(import.meta.url);
15+
const __dirname = path.dirname(__filename);
16+
17+
// Load package.json using fs
18+
const packageJSONPath = path.resolve(__dirname, '../package.json');
19+
const packageJSONBuffer = fs.readFileSync(packageJSONPath);
20+
const packageJSON = JSON.parse(packageJSONBuffer.toString());
1121

1222
program
1323
.version('Version ' + packageJSON.version)

browserbase/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
},
1414
"include": ["src/**/*.ts"],
1515
"exclude": ["node_modules"]
16-
}
16+
}

0 commit comments

Comments
 (0)