-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: implement adapter.emulate
#11732
Conversation
|
|
wrangler@3.25.0 was released yesterday with a miniflare bump, is that the one we're waiting for? |
I think we're waiting for cloudflare/workers-sdk#4847 |
That's landed in 3.26.0, which is available (pre-release) at https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7714710243/npm-package-wrangler-4854 I might try to work out how later anyway, but if it's of any help at all I'd be happy to give it a go to test. |
wrangler 3.26.0 (with the no-op |
I updated my dependencies to: "@sveltejs/adapter-cloudflare": "file:../kit/packages/adapter-cloudflare",
"@sveltejs/kit": "^2.4.3",
"wrangler": "^3.26.0", cloned
removed my if-dev-then-miniflare hacks, and... it seems to be working fine - I'm only using D1 at the moment, but it seems to work exactly as promised; the only local-conditional stuff I have now is to make Drizzle play ball. Thanks! |
Is there anything blocking this at the moment? This would be a huge win for my productivity :) |
@dario-piotrowicz @Rich-Harris is there anything else that needs to be done in this PR? Or does it look good enough after updating to the latest wrangler version and passing in the proxy properties to emulate? |
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
I think it looks great! 😄 From my point of view it looks good and could be shipped 🙂, we can always iterate and improve things if the need arises |
Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com>
Type checking is currently failing because some required fields on platform are not defined in |
I think it would make sense to make all of the properties non-optional since they're now provided during
import { CacheStorage, IncomingRequestCfProperties } from '@cloudflare/workers-types';
declare global {
namespace App {
export interface Platform {
+ /**
+ * Lifecycle methods to augment or control how the request is handled.
+ */
- context?: {
+ context: {
+ /**
+ * Executes a promised-based task before the handler terminates but without blocking the response.
+ *
+ * See the [official docs](https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/#contextwaituntil).
+ *
+ * @param promise
+ */
waitUntil(promise: Promise<any>): void;
};
+ /**
+ * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
+ *
+ * See the [official docs](https://developers.cloudflare.com/workers/runtime-apis/cache/).
+ */
- caches?: CacheStorage;
+ caches: CacheStorage;
+ /**
+ * An object containing properties about the incoming request provided by Cloudflare’s global network.
+ *
+ * See the [official docs](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties).
+ */
- cf?: IncomingRequestCfProperties;
+ cf: IncomingRequestCfProperties;
}
}
} The only issue is that they're not available during |
* add changeset * documentation * Update documentation/docs/25-build-and-deploy/60-adapter-cloudflare.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com> --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com>
Breaking this out of #11730, as the changes to
adapter-cloudflare
andadapter-cloudflare-workers
are blocked on the next release ofwrangler
. Without it, we'll have to makeplatform.caches
optional, which would be an annoying breaking change(Actually, I've just realised that this technically only applies to
adapter-cloudflare-workers
, sincecontext
andcaches
are already optional inadapter-cloudflare
for some reason. But it would be nice to support these in both.)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
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits