Lazy load @ipld/dag-cbor in computeCid (#11099)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-07-10 12:43:04 +03:00
committed by GitHub
parent f1b2bcd638
commit 9b34d357d4
+6 -1
View File
@@ -16,7 +16,6 @@ import {
RichText,
} from '@atproto/api'
import {TID} from '@atproto/common-web'
import * as dcbor from '@ipld/dag-cbor'
import {t} from '@lingui/core/macro'
import {type QueryClient} from '@tanstack/react-query'
import {sha256} from 'js-sha256'
@@ -505,6 +504,12 @@ const mf_sha256 = Hasher.from({
})
async function computeCid(record: AppBskyFeedPost.Record): Promise<string> {
/*
* Lazily loaded since it's only needed when posting a thread, and its
* `cborg` dependency is ~190KB that would otherwise be in the initial
* web bundle.
*/
const dcbor = await import('@ipld/dag-cbor')
// IMPORTANT: `prepareObject` prepares the record to be hashed by removing
// fields with undefined value, and converting BlobRef instances to the
// right IPLD representation.