From 9b34d357d40043a816d6e72a15d99b53a15b43a0 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 10 Jul 2026 12:43:04 +0300 Subject: [PATCH] Lazy load @ipld/dag-cbor in computeCid (#11099) Co-authored-by: Claude Fable 5 --- src/lib/api/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 5a278aeba4..69cc2bf03e 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -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 { + /* + * 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.