Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@danielroe
Copy link
Member

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This adds strong typing for image providers + modifiers throughout, including in the image module options. (For example, a provider that requires you set a baseURL will enforce that in the nuxt config.

This is a breaking change because image providers are now no longer using named exports but a single default export wrapped in a defineProvider function (which can also have an optional setup function).

I've also done quite a lot of cleaning up of types elsewhere, and dropped image props that we weren't using - they should be fine to be attributes inherited by the <img> element.

The next steps will need to be actually getting and setting the types for provider modifiers. (As an interim fix we can support key signatures [key: string]: string | number that would allow the same permissive approach that's working at the moment.)

Because types live in the individual provider files, it should be easy for users to add their own types for custom providers - and also to keep the types in sync for future providers + updates to existing ones.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@1802

commit: bc1e148

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 5, 2025

Deploying nuxt-image with Β Cloudflare Pages Β Cloudflare Pages

Latest commit: bc1e148
Status:Β βœ…Β  Deploy successful!
Preview URL: https://db0666bd.nuxt-image.pages.dev
Branch Preview URL: https://feat-typed-providers.nuxt-image.pages.dev

View logs

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2025

Codecov Report

Attention: Patch coverage is 79.38389% with 174 lines in your changes missing coverage. Please review.

Project coverage is 63.12%. Comparing base (b78c0ea) to head (bc1e148).
Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
src/runtime/providers/filerobot.ts 0.00% 21 Missing ⚠️
src/runtime/providers/ipxStatic.ts 0.00% 19 Missing ⚠️
src/runtime/providers/directus.ts 0.00% 16 Missing ⚠️
src/runtime/providers/cloudimage.ts 56.25% 14 Missing ⚠️
src/runtime/providers/weserv.ts 65.78% 13 Missing ⚠️
src/runtime/providers/sanity.ts 65.71% 12 Missing ⚠️
build.config.ts 0.00% 10 Missing and 1 partial ⚠️
src/runtime/providers/bunny.ts 0.00% 10 Missing ⚠️
src/runtime/providers/caisy.ts 0.00% 10 Missing ⚠️
src/runtime/providers/uploadcare.ts 75.00% 8 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1802      +/-   ##
==========================================
+ Coverage   63.09%   63.12%   +0.03%     
==========================================
  Files          79       77       -2     
  Lines        3785     3824      +39     
  Branches      434      442       +8     
==========================================
+ Hits         2388     2414      +26     
- Misses       1371     1384      +13     
  Partials       26       26              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielroe danielroe marked this pull request as ready for review April 8, 2025 16:42
@danielroe danielroe requested review from atinux and pi0 April 8, 2025 16:42
Copy link
Member

@atinux atinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good changes IMO, I like the defineProvider util!

I let you fix conflicts with pnpm lock before merging of course πŸ˜„

@danielroe danielroe merged commit 3041371 into main Apr 8, 2025
8 of 10 checks passed
@danielroe danielroe deleted the feat/typed-providers branch April 8, 2025 23:31
@github-actions github-actions bot mentioned this pull request Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants