OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-vdrive commits / 23a69cf

Dual-runtime: load under Bare as well as Node
pear-git-v3 and pgh-sidecar run under Bare, so the library has to resolve bare-fs/bare-path there and node builtins under Node. Node 24 does not resolve package #imports to builtins from CJS, so this uses an explicit which-runtime branch with static requires on both sides, which also keeps the dependency visible to bundlers. Verified loading under both runtimes; canary still passes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
23a69cf495e84c53f8bab11a92adb7ee560ce8ae
by plankatron <fleeky@gmail.com> · 2026-08-24T16:22:51.000Z

Changed files (3) +17 -6

lib/overlay-content-store.cjs +5 -2
……@@ -13,8 +13,11 @@
1313// `index` is duck-typed: anything with getChunkMap / getChunkMapByHash works, so
1414// this file does not import hyper-overlay (ESM) into a CJS module.
1515
16const fs = require('fs')
17const path = require('path')
16// Dual-runtime: pgv3 and pgh-sidecar run under Bare, the tests and CLI under Node.
17// Static requires on both branches so bundlers can still see the dependency.
18const { isBare } = require('which-runtime')
19const fs = isBare ? require('bare-fs') : require('fs')
20const path = isBare ? require('bare-path') : require('path')
1821const { ContentStore } = require('./storage.cjs')
1922
2023class OverlayContentStore extends ContentStore {
lib/storage.cjs +4 -1
……@@ -11,7 +11,10 @@
1111// flush — and deleteBlock/deleteBlockRange/truncate free it with no extra work.
1212// Cost: 1 byte per literal block, 33 bytes per virtualised block.
1313
14const fs = require('fs')
14// Dual-runtime: pgv3 and pgh-sidecar run under Bare, the tests and CLI under Node.
15// Static requires on both branches so bundlers can still see the dependency.
16const { isBare } = require('which-runtime')
17const fs = isBare ? require('bare-fs') : require('fs')
1518const crypto = require('hypercore-crypto')
1619const CorestoreStorage = require('hypercore-storage')
1720
package.json +8 -3
……@@ -1,9 +1,11 @@
11{
22 "name": "hyper-vdrive",
33 "version": "0.0.1",
4 "description": "A real Hyperdrive that stores no blob bytes — blocks are materialised on demand from a content-addressed store on disk",
4 "description": "A real Hyperdrive that stores no blob bytes \u2014 blocks are materialised on demand from a content-addressed store on disk",
55 "main": "lib/storage.cjs",
6 "bin": { "vdrive": "bin/vdrive.mjs" },
6 "bin": {
7 "vdrive": "bin/vdrive.mjs"
8 },
79 "exports": {
810 ".": "./lib/storage.cjs",
911 "./overlay": "./lib/overlay-content-store.cjs",
……@@ -14,13 +16,16 @@
1416 "test:gc": "node test/gc-bitfield.mjs ./work/gc"
1517 },
1618 "dependencies": {
19 "bare-fs": "^4.7.1",
20 "bare-path": "^3.0.0",
1721 "corestore": "^7.12.0",
1822 "hypercore": "^11.35.2",
1923 "hypercore-crypto": "^3.7.0",
2024 "hypercore-id-encoding": "^1.3.0",
2125 "hypercore-storage": "^3.2.1",
2226 "hyperdrive": "^13.3.3",
23 "hyperswarm": "^4.17.0"
27 "hyperswarm": "^4.17.0",
28 "which-runtime": "^2.1.1"
2429 },
2530 "license": "AGPL-3.0-or-later"
2631}