Skip to content
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

Core as a set of plugins #96

Open
benmccann opened this issue Nov 14, 2023 · 3 comments
Open

Core as a set of plugins #96

benmccann opened this issue Nov 14, 2023 · 3 comments

Comments

@benmccann
Copy link
Contributor

We just launched @sveltejs/enhanced-img for static images included in the user's project and are now trying to figure out how to handle images from CDNs. I had proposed using @unpic/svelte as our solution there. However, an objection came up that it includes transformers and parsers for all CDNs instead of just the one that the user needs.

It would be nice if we could make core a set of plugins where the user could register just the CDNs they're going to use. Optionally, we could provide a convenience method which registers all providers.

It looks like including the library currently adds about 38 kB unminified and we could probably cut that down a fair amount.

#82 is a bit related to this idea as well

If there's some level of interest, I may be able to contribute to this

@ascorbic
Copy link
Owner

If you need just the transformers you can use unpic, which doesn't have any of the component stuff. The idea for Unpic has always been that it's zero-config. However an optional way of importing the CDNs individually could be a good one

@benmccann
Copy link
Contributor Author

benmccann commented Nov 15, 2023

We do need the component. Maybe we could have just the Svelte component need to be configured? Or maybe it could be exported from the package twice? E.g. import { Image } from "@unpic/svelte"; could give a version which needs to be configured and import { Image } from "@unpic/svelte/full"; could give a version that contains all the providers already configured

(For what it's worth, I just watched this talk and saw at 10m that Angular requires you to configure a provider)

@ascorbic
Copy link
Owner

So I'm still not sold on the actual API within components, but I am publishing a version of the unpic lib with subpath exports for all transformers in the form unpic/transformers/cloudinary etc, and a separate export for unpic/detect. This means you can do detection without the barrel export, and can load the CDNs as needed, and can be a first step to working this out.

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

No branches or pull requests

2 participants