Skip to content

fix: align the SSR environment config with @cloudflare/vite-plugin - #17503

Open
teemingc wants to merge 14 commits into
mainfrom
claude/vite-cloudflare-adapter-settings-796704
Open

teemingc wants to merge 14 commits into
mainfrom
claude/vite-cloudflare-adapter-settings-796704

Conversation

@teemingc

@teemingc teemingc commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

closes #15960

This PR aims to align more closely to a workerd deployment by applying the same environment config that @cloudflare/vite-plugin uses. As a result:

  • all dependencies are bundled and resolved with the workerd/worker export conditions
  • the build uses platform: 'neutral', and Node builtins required from CommonJS become ESM imports (through the plugin's nodejs_compat handling), resolving to the same polyfills workerd uses

One question: would it be safer to label this as a breaking change?


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

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

…ite-plugin`

Applies the Worker environment config generated by `@cloudflare/vite-plugin`
to the SSR build so that dependencies are bundled with the workerd export
conditions and CommonJS `require` calls of Node builtins become imports
instead of `createRequire(import.meta.url)`, which crashes in workerd.

closes #15960

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

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

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

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cc99ea2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-cloudflare Patch

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

@svelte-docs-bot

Copy link
Copy Markdown

@teemingc teemingc changed the title fix: build the server with the environment config from @cloudflare/vite-plugin fix: align the SSR environment config with @cloudflare/vite-plugin Oct 21, 2026
@teemingc teemingc added the needs-platform-tests This PR needs to run platform tests in order to merge. label Oct 21, 2026
"$schema": "../node_modules/wrangler/config-schema.json",
"main": "../dist/index.js",
"compatibility_date": "2026-06-24",
"compatibility_date": "2026-09-01",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The workers test app now uses a compatibility date after 2026-08-04, from which nodejs_compat is enabled by default.

Comment thread packages/adapter-cloudflare/index.js Outdated
};
}

// TODO: move the Vite plugins into their own file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

do this later so that the diff in this PR isn't unreadable

"@sveltejs/kit": "^3.0.0-next.0",
"wrangler": "^4.118.0"
"vite": "^8.0.12",
"wrangler": "^4.151.0"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bumps the wrangler peer dependency to ^4.151.0 to match the Cloudflare Vite plugin.

@teemingc
teemingc marked this pull request as ready for review October 21, 2026 09:25
Comment thread packages/adapter-cloudflare/config.js Outdated
teemingc and others added 4 commits October 21, 2026 19:31
…ctory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ectory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packages/adapter-cloudflare/config.js Outdated
Comment thread packages/adapter-cloudflare/config.spec.js Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-platform-tests This PR needs to run platform tests in order to merge. pkg:adapter-cloudflare

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adapter-cloudflare on Vite 8 (Rolldown): worker fails to start with createRequire(import.meta.url) when a CJS dep uses a Node builtin

1 participant