Skip to content

feat!: typed providers + modifiers#1802

Merged
danielroe merged 10 commits into
mainfrom
feat/typed-providers
Apr 8, 2025
Merged

feat!: typed providers + modifiers#1802
danielroe merged 10 commits into
mainfrom
feat/typed-providers

Conversation

@danielroe

Copy link
Copy Markdown
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

pkg-pr-new Bot commented Apr 5, 2025

Copy link
Copy Markdown

Open in StackBlitz

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

commit: bc1e148

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

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

codecov-commenter commented Apr 5, 2025

Copy link
Copy Markdown

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

@atinux atinux left a comment

Copy link
Copy Markdown
Member

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
@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.

3 participants