-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update and modernize adapter-cloudflare-workers
#4576
Update and modernize adapter-cloudflare-workers
#4576
Conversation
🦋 Changeset detectedLatest commit: 9b8a9a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
||
Generate this file using `wrangler` from your project directory | ||
```toml | ||
[build.upload] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is more opinionated than the last one, which IMO is a better developer experience. Given adapter-cloudflare
builds to .svelte-kit/cloudflare
and requires the user to set it to that path in Pages, I don't think this leaking any more details. That said, I can revert it if the old style, user-provided config is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better if it respects the values in wrangler.toml — the example config we provide in the README/error messages could be the values specified here, but I don't think there's any real benefit to preventing them going somewhere else. For one thing, outDir
is configurable
this overlaps with #4276 |
@dominikg indeed it does, should have looked through PRs before working on it 😅 @benmccann @Rich-Harris what can we do to get this PR or #4276 merged? Any blockers I can help out with? |
does this also fix the reproducible bug i discovered here #4467 |
It does include the change to add esbuild options, but doesn't include the custom mapping function for kv assets. Don't see why we couldn't include that though, I'll add it. |
73f89b1
to
46a4537
Compare
import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler'; | ||
|
||
// Note: This does not get bundled | ||
import manifestJSON from '__STATIC_CONTENT_MANIFEST'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned here, I don't really understand what this is for. It seems duplicative with the data that's already in the SSR manifest, so if it's possible to use that then I think that would be preferable (and if it's not possible, it would be useful to understand why so we can fix it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replied on the other issue here: #4276 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rich-Harris is the explanation I provided reasonable?
46a4537
to
b1fd583
Compare
b1fd583
to
9b8a9a4
Compare
Seems like #4276 is going to take precedence her so going to close this. |
I realize that
adapter-cloudflare
is the preferred solution here since Cloudflare Pages has much more functionality than Workers, but we're stuck in a bind at the moment. Pages is still in beta, and we have more than 100k daily requests for several of our worker apps, more than the beta limit. We've reached out to Cloudflare to see if they could raise the limit for us, but we haven't heard back at all.In the meantime, we're building out more and more infrastructure based on
adapter-cloudflare-workers
, which has some key differences fromadapter-cloudflare
:platform
APIcontext
object passed via theplatform
API, making it impossible to use useful libraries like Toucan.jsesbuild
pipeline when needed (e.g. for Node polyfills).This PR updates
adapter-cloudflare-workers
to use themodules
API instead of the standardservice-worker
setup. This gives it a functionally identical API toadapter-cloudflare
, which will allow us to build our infrastructure in a forward-compatible way that will make transitioning much easier once Pages are out of beta.If this is too big of a change, we can maintain this adapter separately, but I know things are moving quickly and ideally we wouldn't have to keep up with all of the changes as SvelteKit approaches v1. Let me know if this looks good or if anything needs to change, definitely open to feedback and alternatives! Also happy to continue helping out with maintenance for this adapter until Pages is out of beta.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0