From 66336cf2532dfe3018f8754ff2421e855815589f Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Tue, 12 Nov 2024 23:26:05 +0100 Subject: [PATCH] ci: mark build-time variables --- packages/core/src/env.d.ts | 6 ------ packages/core/src/lazyLoad.ts | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 packages/core/src/env.d.ts diff --git a/packages/core/src/env.d.ts b/packages/core/src/env.d.ts deleted file mode 100644 index 8e90531..0000000 --- a/packages/core/src/env.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare global { - const __UNLAZY_HASH_DECODING__: boolean | undefined - const __UNLAZY_LOGGING__: boolean | undefined -} - -export {} diff --git a/packages/core/src/lazyLoad.ts b/packages/core/src/lazyLoad.ts index 9b2e695..f2e33bf 100644 --- a/packages/core/src/lazyLoad.ts +++ b/packages/core/src/lazyLoad.ts @@ -30,6 +30,7 @@ export function lazyLoad( // Generate the blurry placeholder from a Blurhash or ThumbHash string if applicable if ( + // @ts-expect-error: Build-time variable (typeof __UNLAZY_HASH_DECODING__ === 'undefined' || __UNLAZY_HASH_DECODING__) && hash ) { @@ -45,6 +46,7 @@ export function lazyLoad( // Bail if the image does not provide a `data-src` or `data-srcset` attribute if (!image.dataset.src && !image.dataset.srcset) { + // @ts-expect-error: Build-time variable if (typeof __UNLAZY_LOGGING__ === 'undefined' || __UNLAZY_LOGGING__) console.error('[unlazy] Missing `data-src` or `data-srcset` attribute', image) continue @@ -179,6 +181,7 @@ export function createPlaceholderFromHash( return createPngDataUriFromThumbHash(hash) } catch (error) { + // @ts-expect-error: Build-time variable if (typeof __UNLAZY_LOGGING__ === 'undefined' || __UNLAZY_LOGGING__) console.error(`[unlazy] Failed to generate ${hashType} placeholder:`, error) }