From 7b03b4048b5f5595f2c1061cf93193f45b2303e4 Mon Sep 17 00:00:00 2001 From: Koko Nakajima Date: Thu, 13 Mar 2025 16:37:57 -0400 Subject: [PATCH 1/6] prepareCrosswalk updates --- CHANGELOG.md | 6 ++++++ lib/index.js | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49451ac0..890bc168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added +- Check that path exists before calling `getStaticPath` on crosswalk assets in `prepareCrosswalk` +- GIF compatibility for crosswalk assets in `prepareCrosswalk` + ## [0.47.7] - 2024-02-13 ### Added diff --git a/lib/index.js b/lib/index.js index 16afb8a1..2296a2e6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -329,10 +329,11 @@ export class Baker extends EventEmitter { if ( normalizedAssetType === 'img' && !assetSources.jpg && - !assetSources.png + !assetSources.png && + !assetSources.gif ) { throw new Error( - 'Crosswalk: Image assets require either a jpg or png file for basic compatibility.' + 'Crosswalk: Image assets require either a jpg, png or gif file for basic compatibility.' ); } @@ -361,8 +362,10 @@ export class Baker extends EventEmitter { return; } - preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = - this.getStaticPath(path); + if (path && path.length > 0) { + preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = + this.getStaticPath(path); + } }); return acc; From c73f34d9de9af51c3ce674cc979833f78da8883c Mon Sep 17 00:00:00 2001 From: Vanessa Martinez <11972166+vnessamartinez@users.noreply.github.com> Date: Wed, 26 Mar 2025 09:53:16 -0700 Subject: [PATCH 2/6] remove gif --- lib/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2296a2e6..730399b8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -329,11 +329,10 @@ export class Baker extends EventEmitter { if ( normalizedAssetType === 'img' && !assetSources.jpg && - !assetSources.png && - !assetSources.gif + !assetSources.png ) { throw new Error( - 'Crosswalk: Image assets require either a jpg, png or gif file for basic compatibility.' + 'Crosswalk: Image assets require either a jpg or png file for basic compatibility.' ); } From 2df46a57abe8dd886e95c5b31e6caea4845834fe Mon Sep 17 00:00:00 2001 From: Vanessa Martinez <11972166+vnessamartinez@users.noreply.github.com> Date: Wed, 26 Mar 2025 09:53:43 -0700 Subject: [PATCH 3/6] update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 890bc168..556fe18d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Check that path exists before calling `getStaticPath` on crosswalk assets in `prepareCrosswalk` -- GIF compatibility for crosswalk assets in `prepareCrosswalk` ## [0.47.7] - 2024-02-13 From f1ce981aceafaab2efc024647670077fc0ee477c Mon Sep 17 00:00:00 2001 From: Vanessa Martinez <11972166+vnessamartinez@users.noreply.github.com> Date: Tue, 6 May 2025 11:25:36 -0700 Subject: [PATCH 4/6] error message for missing path --- lib/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 730399b8..5575003b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -332,7 +332,7 @@ export class Baker extends EventEmitter { !assetSources.png ) { throw new Error( - 'Crosswalk: Image assets require either a jpg or png file for basic compatibility.' + 'Crosswalk: Image assets require either a jpg or png file for basic compatibility. If you attempted to load a GIF file, they require a png or jpeg fallback for accessibility reasons.' ); } @@ -361,10 +361,12 @@ export class Baker extends EventEmitter { return; } - if (path && path.length > 0) { - preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = - this.getStaticPath(path); + if (!path) { + console.error(`Could not find static path for asset :${normalizedAssetName} and path: ${path}`); + return; } + preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = + this.getStaticPath(path); }); return acc; From ac0784e4aeb2b1cea9875105ea429ba5ae4579de Mon Sep 17 00:00:00 2001 From: Vanessa Martinez <11972166+vnessamartinez@users.noreply.github.com> Date: Tue, 6 May 2025 11:31:50 -0700 Subject: [PATCH 5/6] error message update --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5575003b..15a32fee 100644 --- a/lib/index.js +++ b/lib/index.js @@ -362,11 +362,13 @@ export class Baker extends EventEmitter { } if (!path) { - console.error(`Could not find static path for asset :${normalizedAssetName} and path: ${path}`); + console.error( + `Could not find static path for asset: ${normalizedAssetName} with the extension: ${ext}` + ); return; } preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = - this.getStaticPath(path); + this.getStaticPath(path); }); return acc; From 603bf935bf05b4f283d4444db5f54781cb1a70cf Mon Sep 17 00:00:00 2001 From: Vanessa Martinez <11972166+vnessamartinez@users.noreply.github.com> Date: Tue, 6 May 2025 11:53:07 -0700 Subject: [PATCH 6/6] warning instead of error --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 15a32fee..da0354ff 100644 --- a/lib/index.js +++ b/lib/index.js @@ -362,8 +362,8 @@ export class Baker extends EventEmitter { } if (!path) { - console.error( - `Could not find static path for asset: ${normalizedAssetName} with the extension: ${ext}` + console.warn( + `Could not find static path for asset: ${normalizedAssetName} with the extension: ${ext}. Skipping.` ); return; }