fix: update Cloudflare adapter's default image service#15435
fix: update Cloudflare adapter's default image service#15435Princesseuh merged 21 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 233774b The changes in this PR will be included in the next version bump. 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 |
@astrojs/cloudflare/image-endpoint for Cloudflare dev server|
Why not keep compile as the default? doesn't this fix compile in dev as well? |
Realized I misread this, yes compile now works in dev by using passthrough, but it's not an amazing default experience to have image optimization be noop so bindings should lead to a better experience |
This comment was marked as outdated.
This comment was marked as outdated.
|
This PR is missing a changeset |
|
I'll do the changeset once I actually know what we're doing. What the PR actually does has already changed twice since its creation |
83a206a to
4ffe2d0
Compare
fa86b90 to
a1237c1
Compare
|
I don't mean to hijack this, we can move the 66a44d7 out of here if we want but I figured it's easier to keep all in context at least to get some feedback the idea is this will fix compile and then it opens the quesiton up if we do fix compile and everything works properly which do we want as the default? Netlify adapter I think now defaults to the equivalent of |
a1237c1 to
d4c29ff
Compare
|
I still think |
d4c29ff to
0f97375
Compare
0f97375 to
66a44d7
Compare
|
Here's a little ai overview of the commit, because its a bit dense Commit Breakdown: `66a44d7` — feat: fix/improve compile1. Refactor
|
sarah11918
left a comment
There was a problem hiding this comment.
Ugh, apparently I had a pending review comment here
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@astrojs/cloudflare": minor | |||
There was a problem hiding this comment.
Just checking that changing a default setting is a potentially a breaking change, and probably a major?
Will note that this requires an entry in the specific Cloudflare upgrade guide, so if you want to follow the pattern for other major upgrades and simply write a one-liner, then link to the docs there, that would be fine!
matthewp
left a comment
There was a problem hiding this comment.
Very clever approach to generating the list in the workerd side and then passing back over to Node.js side for sharp processing. Very nicely done!
|
Does this also fix #15437? |
Yes |
|
@rururux i'm ready to merge the PR once the conflicts are resolved |
|
Sorry, I was a bit slow to react! 😅 Thanks for jumping in and handling this, @Princesseuh! |
|
Will note that something came up while preparing the docs that I think is relevant to ask here! withastro/docs#13267 (comment) |
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
sarah11918
left a comment
There was a problem hiding this comment.
Approving for docs, and the docs PR is also approved for merging when the feature is released!
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
|
When I first opened this pull request, I never imagined it would grow into something this big. Thank you all so much! |
fixes #15319, fixes #15437
From @Princesseuh:
Updates the default option for the Cloudflare adapter to use the bindings by default, and fix the dev experience on all the other settings. In v6 sharp cannot work in dev anymore because it doesn't run in workerd, so everything became passthrough.
Additionally, this PR changes how we do the picomatch excludes to ensure we don't import CJS at runtime in the endpoint. Sucks that picomatch is still in CJS.
Docs: withastro/docs#13267
Original comment here
Changes
Previously, an error occurred when using the Cloudflare adapter in combination with the
<Image />component. This issue is caused by Astro's default behavior: when no image entrypoint is specified in a development environment, it defaults toastro/assets/endpoint/dev.astro/packages/astro/src/assets/endpoint/config.ts
Lines 24 to 29 in 840fbf9
Since this default dev entrypoint depends on Vite, it attempts to bundle Vite as a dependency during the development server build, leading to the error.
astro/packages/astro/src/assets/endpoint/dev.ts
Line 6 in 840fbf9
To resolve this, I have updated the Cloudflare adapter to automatically use
@astrojs/cloudflare/image-endpointas the image entrypoint for development.There might be a more optimal way to specify this configuration, but I couldn't come up with a better alternative at this time.
I am submitting this PR as-is for initial review.
Testing
I have updated
compile-image-service.test.js, which is affected by this change, to include tests for the development server.While it may be necessary to add tests covering all
imageServiceoptions, I have left it as is for now to facilitate the review process.Docs
N/A