Update Cloudflare imageService docs for custom image service support#14095
Update Cloudflare imageService docs for custom image service support#14095adamchal wants to merge 1 commit into
imageService docs for custom image service support#14095Conversation
Clarify that `compile` mode uses a configured custom `image.service` when defined (running its `getURL()`/`getHTMLAttributes()` hooks during prerendering), and that `custom` mode now also generates optimized assets at build time via the service's `transform()` hook, without bundling Sharp when it is not needed. See withastro/astro#17099.
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
Hello! Thank you for opening your first PR to Astro’s Docs! 🎉 Here’s what will happen next:
|
|
Preview deployment ✅ Deployment complete!
|
ArmandPhilippot
left a comment
There was a problem hiding this comment.
Thank you, and welcome. Sorry for the delay, with v7 release, I didn't have the chance to review this sooner!
I don't know if this is because I'm not familiar enough with Cloudflare but the lengthy explanations from the two PRs confused me a bit. I hope I got it right. 😄 Feel free to double check the accuracy of my suggestions!
What bothers me currently is that some elements look like implementation details (so, not helpful for the user), and it isn't really clear what falls under pre-rendering versus on-demand rendering.
| - **`passthrough`:** Uses the existing [`noop`](/en/guides/images/#configure-no-op-passthrough-service) service. | ||
| - **`compile`:** Uses a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. | ||
| - **`custom`:** Always uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options). **This option will not check to see whether the configured image service works in Cloudflare's `workerd` runtime.** | ||
| - **`compile`:** Uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options) if one is defined, running its custom `getURL()` and `getHTMLAttributes()` hooks while prerendering. Otherwise, it uses a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. |
There was a problem hiding this comment.
Does mentioning "getURL() and getHTMLAttributes() hooks" important to the user? I'm not familiar with Cloudflare, but this sounds like an implementation detail to me.
It's also not clear to me if the behavior has changed for on-demand rendering. I would say no IIUC, but then the suggested description might be a bit confusing.
Maybe the following is enough:
| - **`compile`:** Uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options) if one is defined, running its custom `getURL()` and `getHTMLAttributes()` hooks while prerendering. Otherwise, it uses a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. | |
| - **`compile`:** Uses the [configured image service](/en/reference/configuration-reference/#imageservice) or falls back to a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. |
| - **`compile`:** Uses a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. | ||
| - **`custom`:** Always uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options). **This option will not check to see whether the configured image service works in Cloudflare's `workerd` runtime.** | ||
| - **`compile`:** Uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options) if one is defined, running its custom `getURL()` and `getHTMLAttributes()` hooks while prerendering. Otherwise, it uses a combination of internal dependencies to transform images locally at build time for prerendered routes. The noop `passthrough` option is configured for on-demand rendered pages. | ||
| - **`custom`:** Always uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options), both for runtime image handling and for build-time asset generation for prerendered routes, where its `transform()` hook runs at build time. Sharp is not bundled into the worker when the configured service does not require it. **This option will not check to see whether the configured image service works in Cloudflare's `workerd` runtime.** |
There was a problem hiding this comment.
Same here "where its transform() hook runs at build time" sounds like an implementation detail to me and the user doesn't need to know that?
And I'm not sure "Sharp is not bundled into the worker when the configured service does not require it." is the right wording.
Maybe something like:
| - **`custom`:** Always uses the image service configured in [Image Options](/en/reference/configuration-reference/#image-options), both for runtime image handling and for build-time asset generation for prerendered routes, where its `transform()` hook runs at build time. Sharp is not bundled into the worker when the configured service does not require it. **This option will not check to see whether the configured image service works in Cloudflare's `workerd` runtime.** | |
| - **`custom`:** Uses the [configured image service](/en/reference/configuration-reference/#imageservice) (defaults to Sharp) to process assets at build time for prerendered routes. Bundles the image service for runtime image handling, without checking its compatibility with Cloudflare's `workerd` runtime. |
If you think adding "Sharp is not compatible." at this end is helpful, I don't mind! But, I think it makes more sense to point out that Sharp is the default and that's why it could be bundled rather than your wording.
Clarify that
compilemode uses a configured customimage.servicewhen defined (running itsgetURL()/getHTMLAttributes()hooks during prerendering), and thatcustommode now also generates optimized assets at build time via the service'stransform()hook, without bundling Sharp when it is not needed.See withastro/astro#17099.
Description (required)
Two mode descriptions were out of date:
compilepreviously always used the adapter's internal workerd image service. It now uses the configuredimage.serviceif one is defined (running its customgetURL()andgetHTMLAttributes()hooks while prerendering), and falls back to the internal dependencies only when no custom service is set.custompreviously ran only at runtime. It now also generates optimized image assets at build time for prerendered routes (the service'stransform()hook runs at build), and Sharp is no longer bundled into the worker when the configured service does not need it.The edits keep the existing bullet structure, reuse the existing Image Options link, and preserve the existing
workerdruntime caveat oncustom.Related issues & labels (optional)
compile+custom) astro#17099improve or update documentationDiscord username: adam.chal