-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: stable release #748
feat: stable release #748
Conversation
🦋 Changeset detectedLatest commit: 13b27cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for unpic-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for unpic-angular ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for unpic-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Co-authored-by: Bert Bengtson <[email protected]> Co-authored-by: Matt Kane <[email protected]>
I think it'd probably be nice to have a way to be able to set a default transformer. I haven't used CDNs much, so don't know how much of an issue it is to have to set the transformer each time you have an image, but it feels like it'd be easier to do it just once for the whole app. |
@benmccann it's hard to set defaults outside of a metaframework. Even using env vars has caused issues in the places I tried it, because of platform-specific differences. In most cases the best approach is to create your own wrapper component, though obviously the syntax for that varies by framework too. That lets you import just the transformer you need. |
Yeah, wrapper component seems like a good solution. Might be worth explicitly suggesting that in the docs if it's not already |
@benmccann I added exactly that this morning! https://deploy-preview-748.preview.unpic.pics/custom/ |
This is a major update, with changes to the API of all frameworks. This will not affect you if you are just using the components with default options, but if you are passing custom transformers or specifying the CDN then you will need to update your code.
To try it, install the preview build from pkg.pr.new
The new provider transformers and types are implemented in ascorbic/unpic#133
Breaking changes
cdnOptions
property has been removed. Use the newoptions
property instead.transformer
property has been removed from the defaultImage
component. Import the base component and specify the transformer there instead. The type signature for the transformer has also changed. See theunpic
library documentation for more information.cdn
property has been removed. Either use the newfallback
property or import the base component and pass a single provider to it.Changes
Most of the changes are because of a new approach to handling individual image CDNs and providers in the base Unpic library. This is designed to make Unpic more flexible, efficient and modular. It also introduces support for type-safe custom operations and options for each provider.
Provider operations
Supported frameworks: All except
webc
andlit
.The new
operations
property allows you to specify custom operations for each provider. Many image CDNs support dozens of custom operations. Previously these were hard to use with Unpic. The newoperations
property gives type-safe support for all supported features of each provider. This works even if you have images from multiple providers in the same component, as you can specify options for each provider separately.The operations are all type-safe, with JSDoc comments and TypeScript definitions for all supported operations. This means you can get autocompletion and type checking for all operations.
Provider options
Supported frameworks: All except
webc
andlit
.The new
options
property allows you to specify custom options for each provider. This is similar to the currentcdnOptions
property, but with type-safe support for all options of each provider. This allows you to specify options such as account IDs and domains for each provider.Fallback providers
Supported frameworks: All. The
astro
andnextjs
frameworks default to the framework's image provider as fallback.The new
fallback
property allows you to specify a fallback provider for each image. This allows you to use auto-detection for image CDNs as now, but also specify a fallback provider for local images and images from unknown providers. This is useful if you have a mix of images from different sources, and want to ensure that all images are handled correctly. For example, you may have a Contentful blog hosted on Netlify, with images that are mostly hosted on Contentful (a supported CDN), but also some images from third-parties or your own server. You can specify Netlify as the fallback provider so that it uses the Netlify Image CDN for all images that are not from Contentful or another supported provider. This will be all handled automatically.Base component
Supported frameworks: All except
webc
,lit
andangular
.Previously, the
Image
andSource
components always loaded support for every provider, even if you specified a single provider or custom transformer. This is fine if you are using auto-detection, but many people wanted to use the components in a more custom or modular way. The new base components allow you to use the Unpic component without any of the automatic detection and transform logic. You can provide your own transformer, or use a single, tree-shakable provider import. This is useful if you are using a single provider, or if you are building a custom component based on Unpic.The
operations
andoptions
properties are still type-safe and inferred from the transformer, and you don't need to specify the provider name in theoperations
object.