Skip to content

Commit a9b20c6

Browse files
committed
revert: remove lazy-loading of bun lockfile parser
Reverted to simple top-level require() as lazy-loading is not needed. The dependency should be available at module load time.
1 parent 651a7e5 commit a9b20c6

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

packages/cli/src/utils/ecosystem/environment.mts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,11 @@ import browserslist from 'browserslist'
3232
import semver from 'semver'
3333

3434
const require = createRequire(import.meta.url)
35-
36-
// Lazy-load Bun lockfile parser only when needed.
37-
let parseBunLockb: ((buf: Uint8Array | ArrayBuffer) => string) | undefined
38-
39-
function getParseBunLockb() {
40-
if (!parseBunLockb) {
41-
// Type definition is incorrect - exports object with parse method, not namespace.
42-
const parser = require('@socketregistry/hyrious__bun.lockb/index.cjs') as {
43-
parse: (buf: Uint8Array | ArrayBuffer) => string
44-
}
45-
parseBunLockb = parser.parse
35+
// Type definition is incorrect - exports object with parse method, not namespace.
36+
const { parse: parseBunLockb } =
37+
require('@socketregistry/hyrious__bun.lockb/index.cjs') as {
38+
parse: (buf: Uint8Array | ArrayBuffer) => string
4639
}
47-
return parseBunLockb
48-
}
4940

5041
import { whichBin } from '@socketsecurity/lib/bin'
5142
import {
@@ -220,7 +211,7 @@ const readLockFileByAgent: Map<Agent, ReadLockFile> = (() => {
220211
const lockBuffer = await binaryReader(lockPath)
221212
if (lockBuffer) {
222213
try {
223-
return getParseBunLockb()(lockBuffer)
214+
return parseBunLockb(lockBuffer)
224215
} catch {}
225216
}
226217
// To print a Yarn lockfile to your console without writing it to disk

0 commit comments

Comments
 (0)