feat: Cloudflare Vite plugin integration - #15627
Conversation
This reverts commit eaffa39.
🦋 Changeset detectedLatest commit: 8970286 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 |
| await expect(page.locator('#var')).toHaveText(`Var: ${prod_string}VAR`); | ||
| }); | ||
|
|
||
| test('serves static assets with assets path prefix', async ({ page, request }) => { |
There was a problem hiding this comment.
Not really sure how to get this test passing in the Cloudflare environment. Vite doesn't enforce consumers to allow us to run arbitrary code during preview so an alternative might be to have process.env.SVELTEKIT_ASSETS as an override which we set before anything else starts?
…1 (steps 1-3) Steps 1-3 of docs/jazz-to-cloudflare-migration.md: - Provision D1 + per-show ShowRoom and singleton ShowDirectory Durable Object bindings in wrangler.jsonc; generate binding types (pnpm cf:types). - Switch SvelteKit to @sveltejs/adapter-cloudflare. Because the released adapter (pre sveltejs/kit#15627) writes its worker to wrangler's `main`, a second config (wrangler.adapter.jsonc) drives the adapter's output while the real wrangler.jsonc `main` is src/worker.ts — a custom entry that imports the built SvelteKit worker, re-exports the Durable Objects, and wraps fetch with @sentry/cloudflare. - Port server Sentry to @sentry/cloudflare; delete instrumentation.server.ts and the adapter-node tracing/instrumentation settings. - Move Better Auth off jazzAdapter to a per-request createAuth(env) factory using the Drizzle / drizzle-orm/d1 adapter. Hand-authored D1 schema (auth tables + registry: shows/showHosts/hostLinks) with a partial unique index enforcing one live show. drizzle-kit migrations applied to local D1. - DEV_AUTH-gated dev-auth bypass (/dev-login) seeding an admin and a viewer, minting real JWKS-signed JWTs (verified: admin is_admin:true, viewer false). - Repoint auth:schema/db:reset; drop auth:validate. Add cf:types/db:* scripts. Deviations (documented): raw Durable Objects + WebSocket Hibernation API instead of PartyServer; wrangler dev against the build is the DO-capable runtime loop instead of @cloudflare/vite-plugin's vite dev, which cannot run a custom DO-exporting worker entry with the current SvelteKit adapter. Jazz data path goes dark mid-migration (single branch, no dual-path), restored on the new stack in steps 4-5. check/lint/build all green; app + auth verified under wrangler dev via Chrome DevTools. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Links the two live upstream tracks: sveltejs/kit#15627 (adapter-cloudflare adopting @cloudflare/vite-plugin) and the Durable Object / Workflow export gap in cloudflare/workers-sdk#14013. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
tested this PR against a real production app: SvelteKit + a Durable Object (voice agent) exported from the same Worker, WebSockets, Workers AI with Setup: installed via Findings, in the order we hit them:
Happy to re-test on this app as the PR evolves; it exercises pretty much everything at once (DO + WebSockets + remote AI bindings + custom entrypoint), so it's a decent canary. |
closes #16361 This PR adds the Cloudflare Workers-specific condition `workerd` to the imports list in `package.json` so that Wrangler stops resolving to the `browser` condition which exposes client-side code. It's a quick fix that isn't needed if we land #15627 which simply removes the `browser` condition added by the Cloudflare Vite plugin for the build. Once we use Cloudflare's Vite plugin, the builds get deployed unbundled so we don't have to worry about Wrangler rebundling with the `browser` condition like we do now. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. ### Tests - [ ] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
|
Going to close this one until we can make better sense of the fetchable dev environment API in a way that doesn't make Kit worse for other platforms |
@teemingc I kinda don't understand this decision. What are the limits of the current Vite plugin/or the feature that would be worse for the other platforms supporting this? I personally tested SvelteKit 3 with this, and the only issue I had was the SERVER/MANIFEST error I linked (#15627 (comment)). I also understand that I am missing some context on new features / architectural decisions, but for a Vite-based meta framework, it seems odd that it cannot support a Vite Plugin. I am sorry for the next phrase. I really hope this is not a decision stemming from the ongoing Vercel/Cloudflare feud. |
The main issue is that supporting Vite's
Not to worry, I'm not even paid by Vercel 😆; I'm supported by the Svelte open collective (in fact, I'm a happy Cloudflare user and have been using it to host church sites for a few years now). Also, we haven't given up yet. We're still thinking about the best way to do this that doesn't require such a massive change. Will report back soon if my findings are successful. |
closes #10496
closes #13692
closes #1712
closes #2963
closes #13300
closes #1519
This PR removes support for Cloudflare Pages and integrates with the Cloudflare Vite plugin. Users can now:
TODOs
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits