feat: add pattern for runtime specific package dependencies (#8320)

**Motivation**

Make sure the Lodestar starts running in Bun runtime. 

**Description**

- Add subpath imports supported in Bun and NodeJS. 
- 

**Steps to test or reproduce**

Run all tests 

**Note**

The CLI finally starts to run, next go with command by command to see
what's breaking, starting the `beacon` cmd.

```
bun run --bun bin/lodestar.js --help 
🌟 Lodestar: TypeScript Implementation of the Ethereum Consensus Beacon Chain.

 * Version: v1.33.0/nh/bun-wrappers/07d2010
  * by ChainSafe Systems, 2018-2025

Commands:
  beacon       Run a beacon chain node
  validator    Run one or multiple validator clients
  lightclient  Run lightclient
  dev          Quickly bootstrap a beacon node and multiple validators. Use for
               development and testing
  bootnode     Run a discv5 bootnode. This will NOT perform any beacon node func
               tions, rather, it will run a discv5 service that allows nodes on
               the network to discover one another.

Options:
      --dataDir                             Lodestar root data directory[string]
      --network                             Name of the Ethereum Consensus chain
                                             network to join
  [string] [choices: "mainnet", "gnosis", "sepolia", "holesky", "hoodi", "chiado
                                        ", "ephemery", "dev"] [default: mainnet]
      --paramsFile                          Network configuration file  [string]
      --rcConfig                            RC file to supplement command line a
                                            rgs, accepted formats: .yml, .yaml,
                                            .json                       [string]
      --supernode                           Subscribe to and custody all data co
                                            lumn sidecar subnets       [boolean]
      --terminal-total-difficulty-override  Terminal PoW block TTD override
                                                                        [string]
      --terminal-block-hash-override        Terminal PoW block hash override
                                                                        [string]
      --terminal-block-hash-epoch-override  Terminal PoW block hash override act
                                            ivation epoch               [string]
  -h, --help                                Show help                  [boolean]
  -v, --version                             Show version number        [boolean]

📖 For more information, check the CLI reference:
  * https://chainsafe.github.io/lodestar/reference/cli

✍️ Give feedback and report issues on GitHub:
  * https://github.com/ChainSafe/lodestar

```
This commit is contained in:
Nazar Hussain
2025-09-19 16:10:20 +02:00
committed by GitHub
parent 36a31f3a2f
commit 7a3b3a996e
4 changed files with 17 additions and 1 deletions

View File

@@ -28,6 +28,9 @@
"!packages/**/*/node_modules/"
]
},
"javascript": {
"globals": ["Bun"]
},
"linter": {
"rules": {
"correctness": {

View File

@@ -51,6 +51,12 @@
"import": "./lib/util/index.js"
}
},
"imports": {
"#prometheus-gc-stats-wrapper": {
"bun": "./lib/bun-wrappers/prometheus-gc-stats.js",
"default": "@chainsafe/prometheus-gc-stats"
}
},
"typesVersions": {
"*": {
"*": [

View File

@@ -0,0 +1,7 @@
// Bun does not support `GCProfiler` from `node:v8`a
// Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
// So we expose a dummy function for Bun runtime which do nothing for now
// TODO: May look get some useful data from `bun:jsc`
export function gcStats() {
return () => {};
}

View File

@@ -1,4 +1,4 @@
import {gcStats} from "@chainsafe/prometheus-gc-stats";
import {gcStats} from "#prometheus-gc-stats-wrapper";
import {Registry, collectDefaultMetrics} from "prom-client";
export function collectNodeJSMetrics(register: Registry, prefix?: string): () => void {