fix: terminate the build process when font resolution fails#518
fix: terminate the build process when font resolution fails#518cernymatej wants to merge 1 commit intonuxt:mainfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #518 +/- ##
==========================================
- Coverage 82.84% 82.73% -0.11%
==========================================
Files 13 13
Lines 1067 1066 -1
Branches 264 268 +4
==========================================
- Hits 884 882 -2
- Misses 178 179 +1
Partials 5 5 ☔ View full report in Codecov by Sentry. |
|
It's possible that nuxt/fonts might process something that isn't a valid font (and therefore can't resolve it). So I think the scenarios we should care about are:
|
|
Could you please share an example of a case where something fails to resolve, but we wouldn’t want to throw an error here? 🙏 I'd like to test it. The Line 211 in 6632fa2 Are you suggesting that we should throw an error when a failure occurs in these places instead? Downloading registries Downloading font details Downloading fonts Line 153 in 6632fa2 (probably unnecessary, since errors aren’t caught here anyway - we can keep the fetch error, if it occurs) |
|
It might fail - I think - if the font family isn't a web font or if it's processing a css variable which doesn't have a font family. |
|
we can use unjs/unifont#161 once the next release of unifont |
🔗 Linked issue
resolves #356
❓ Type of change
📚 Description
This will ensure that the build process is terminated when the font face declarations cannot be produced, preventing a project with broken fonts from being deployed.
I'm wondering if this should be addressed upstream in
unifontas well.https://github.com/unjs/unifont/blob/f4d3efae764b78ab4c11cf303e465ecf5b95c1a4/src/index.ts#L55-L57
https://github.com/unjs/unifont/blob/f4d3efae764b78ab4c11cf303e465ecf5b95c1a4/src/index.ts#L79-L81
However, that would likely require a major version bump since it would be a breaking change. Then again, it might not be necessary, as one could simply check the return value to determine whether the resolution was successful.