πŸ“„ File detail

utils/crypto.ts

🧩 .tsπŸ“ 14 linesπŸ’Ύ 763 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes randomUUID β€” mainly functions, hooks, or classes. Dependencies touch crypto. What the file header says: Indirection point for the package.json "browser" field. When bun builds browser-sdk.js with --target browser, this file is swapped for crypto.browser.ts β€” avoiding a ~500KB crypto-browserify polyfill that Bun would otherwise inline for `import ... from 'crypto'`. Node/bun builds.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Indirection point for the package.json "browser" field. When bun builds browser-sdk.js with --target browser, this file is swapped for crypto.browser.ts β€” avoiding a ~500KB crypto-browserify polyfill that Bun would otherwise inline for `import ... from 'crypto'`. Node/bun builds use this file unchanged. NOTE: `export { randomUUID } from 'crypto'` (re-export syntax) breaks under bun-internal's bytecode compilation β€” the generated bytecode shows the import but the binding doesn't link (`ReferenceError: randomUUID is not defined`). The explicit import-then-export below produces a correct live binding. See integration-tests-ant-native failure on PR #20957/#21178.

πŸ“€ Exports (heuristic)

  • randomUUID

πŸ“š External import roots

Package roots from from "…" (relative paths omitted).

  • crypto

πŸ–₯️ Source preview

// Indirection point for the package.json "browser" field. When bun builds
// browser-sdk.js with --target browser, this file is swapped for
// crypto.browser.ts β€” avoiding a ~500KB crypto-browserify polyfill that Bun
// would otherwise inline for `import ... from 'crypto'`. Node/bun builds use
// this file unchanged.
//
// NOTE: `export { randomUUID } from 'crypto'` (re-export syntax) breaks under
// bun-internal's bytecode compilation β€” the generated bytecode shows the
// import but the binding doesn't link (`ReferenceError: randomUUID is not
// defined`). The explicit import-then-export below produces a correct live
// binding. See integration-tests-ant-native failure on PR #20957/#21178.
import { randomUUID } from 'crypto'
export { randomUUID }