-
Notifications
You must be signed in to change notification settings - Fork 76
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
Reduce Client Bundle Size #519
Comments
Hey @wottpal we're currently working on how this project is bundled and hope to improve this as part of that project, with part of the primary goal being to provide better support for using the components in RSCs. will update when we have more to share |
Nice, also the RSC part is great news. A bit unrelated but speaking of RSC, I've built myself a server component wrapper around const fetchImageDataUrl = unstable_cache(
async (url) => {
const response = await fetch(url)
const arrayBuffer = await response.arrayBuffer()
const base64String = Buffer.from(arrayBuffer).toString('base64')
const mimeType = response.headers.get('Content-Type') || 'image/jpeg'
const dataUrl = `data:${mimeType};base64,${base64String}`
return dataUrl
},
['image-data-url'],
)
interface CldImageWithPlaceholderProps extends ImageProps {
src: string
}
export default async function CldImageWithPlaceholder({
src,
...props
}: CldImageWithPlaceholderProps) {
if (props.placeholder === 'blur') {
try {
const url = getCldImageUrl({
src,
width: 10,
height: 10,
format: 'jpg',
})
props.blurDataURL = await fetchImageDataUrl(url)
} catch (error) {
props.placeholder = 'empty'
console.error(`Error fetching Cloudinary URL (${src}):`, error)
}
}
return <CldImage src={src} {...props} />
} |
oh nice one! i did something somewhat similar in an example in this guide: https://next.cloudinary.dev/guides/placeholders |
Uh nice one, didn't saw that. would have saved me some time haha. You can close this issue or use it to track the module restructurment progress – Feel free to handle it as you like. |
I was wondering if the noticeable client bundle size of
next-cloudinary
is justified somehow? I'm only usingCldImage
within a client component in this case.Could the package maybe split into multiple parts?
The text was updated successfully, but these errors were encountered: