Skip to content
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

adds cloudflare cf object to platform property #10873

Merged
merged 1 commit into from
Oct 25, 2023
Merged

adds cloudflare cf object to platform property #10873

merged 1 commit into from
Oct 25, 2023

Conversation

philippviereck
Copy link
Contributor

this has been done for the pages package but not for workers. see #9978

// @ts-expect-error req is actually a Cloudflare request not a standard request
cf: req.cf

This is a bit ugly, but changing the JSDoc req to {import('@cloudflare/workers-types').Request} req causes even more errors

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

this has been done for the pages package but not for workers.
see #9978
@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2023

🦋 Changeset detected

Latest commit: 115c8bd

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-workers Minor

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

@benmccann benmccann merged commit 799b9e7 into sveltejs:master Oct 25, 2023
12 of 13 checks passed
@github-actions github-actions bot mentioned this pull request Oct 25, 2023
@benmccann
Copy link
Member

I went ahead and merged this, but I wonder if there's a reason you don't just switch to adapter-cloudflare? It has about 50x as much usage, so we might deprecate @sveltejs/adapter-cloudflare-workers at some point

https://npmcharts.com/compare/@sveltejs/adapter-cloudflare,@sveltejs/adapter-cloudflare-workers?log=true&interval=7

@philippviereck
Copy link
Contributor Author

philippviereck commented Oct 26, 2023

@benmccann there's a couple off reasons to use the workers adapter over the pages one:

  • wrangler.toml
  • durable objects (you need to deploy them separately when using pages)
  • control over output (the workers adapter output is the exact code that runs on CF, where as the pages adapter outputs _worker.js which gets magically converted by cloudflare to pages Functions -
    this is an issue when working with sourcemaps. e.g. you CAN'T use @sveltejs/adapter-cloudflare properly with Sentry.io)

TL;DR @sveltejs/adapter-cloudflare-workers offers granular control over the code deployed/running on CF.

Please don't deprecate @sveltejs/adapter-cloudflare-workers until cloudflare brings said features to pages. (they plan to do so I think)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants