Files
bsky-social-app/src/lib/media/video/mediabunny.ts
T
Oleksii Bulenok 8aebe314aa prettier
2026-08-24 12:33:38 +02:00

19 lines
616 B
TypeScript

type MediaBunnyModule = typeof import('mediabunny')
let promise: Promise<MediaBunnyModule> | undefined
/**
* Lazily loads mediabunny into its own async chunk and caches the resulting
* promise so the module is fetched at most once. If the import fails (e.g. a
* transient chunk-load error), the cached promise is reset so a later call can
* retry the load.
*/
export function loadMediaBunny(): Promise<MediaBunnyModule> {
promise ??= import('mediabunny').catch(e => {
// reset so a later attempt can retry after a transient chunk-load failure
promise = undefined
throw e
})
return promise
}