Skip to content

feat: @cloudflare/vite-plugin integration, take 2 - #16705

Draft
ottomated wants to merge 4 commits into
version-3from
cloudflare-vite-plugin-2
Draft

feat: @cloudflare/vite-plugin integration, take 2#16705
ottomated wants to merge 4 commits into
version-3from
cloudflare-vite-plugin-2

Conversation

@ottomated

@ottomated ottomated commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

closes #10496
closes #13692
closes #1712
closes #2963
closes #13300
closes #1519

Draft attempt to get @cloudflare/vite-plugin to work without having to implement FetchableDevEnvironment. This means that sveltekit will still be running inside node instead of workerd, but enables custom worker entrypoints with full support for durable objects (including websockets in local dev), workflows, etc.

TODO:


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • 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
  • 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

  • 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:.

@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from f356c53:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/f356c53f8ad0cde513cbd0c4757b823b95c3420d

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16705

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f356c53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

type Span = import('@opentelemetry/api').Span;

// @ts-ignore see above
type ServerResponse = import('http').ServerResponse;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? I don't know if node types are guaranteed to be installed


export { init_tracing, otel, record_span } from './telemetry.js';

export { dedent } from '../../../core/sync/utils.js';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel weird about this

],
post_plugins: [
// ...or here to integrate with Vite
]

@teemingc teemingc Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to solve this with order: 'pre' and order: 'post' on the plugin hook itself? If it isn't, I think we can add this public API in a separate PR before Kit 3 is out so that it's not a breaking change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloudflare/vite-plugin (like sveltekit) consists of a bunch of smaller plugins that are order sensitive, and it needs to go after sveltekit. I tried setting enforce: post on each of them and it broke things.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we add vite.plugins.pre and vite.plugins.post in a new PR?

@teemingc

Copy link
Copy Markdown
Member

I think we should try to do this in stages of several PRs:

  1. Add vite.plugins.pre and vite.plugins.post
  2. Add the Cloudflare Vite plugin (build-only)
  3. Custom worker entry file
  4. Cloudflare Vite plugin (dev)
  5. WebSockets (maybe this can be at the same time as 4 depending on the size of changes)

teemingc added a commit that referenced this pull request Aug 10, 2026
part of #16705

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [ ] 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
- [ ] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests
- [x] 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:`.

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants