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

Make wrangler optional when installing the Cloudflare adapters #11986

Open
eltigerchino opened this issue Mar 15, 2024 · 2 comments · May be fixed by #12452
Open

Make wrangler optional when installing the Cloudflare adapters #11986

eltigerchino opened this issue Mar 15, 2024 · 2 comments · May be fixed by #12452

Comments

@eltigerchino
Copy link
Member

eltigerchino commented Mar 15, 2024

Describe the problem

Currently, we use wrangler to emulate the event.platform variable for cloudflare bindings, etc during development.

But the wrangler package is pretty big and is not exactly essential if you're not planning on using any of the cloudflare services such as D1 databases, etc. (which is unlikely) or if you're just creating a quick repro on stackblitz. This makes dependency install times much longer (potentially affecting CI/CD for builds and tests? I'm not well versed in that area).

Additionally, your app simply won't run on environments such as stackblitz where workerd is not supported.
https://stackblitz.com/edit/sveltejs-kit-template-default-rnvvem?file=svelte.config.js

cc: @dario-piotrowicz how are other frameworks handling this? and is this even worth pursuing?

Describe the proposed solution

Is it possible for us to make it an optional dependency or a peer optional dependency? Would that prevent it from being installed automatically?

Alternatives considered

Maybe this isn't even worth pursuing and we'd only want the cloudflare adapters to work in environments that can run a workerd emulation by wrangler.

Importance

nice to have

Additional Information

No response

@eltigerchino eltigerchino changed the title Make wrangler optional when installing the cloudflare adapters Make wrangler optional when installing the cloudflare adapters Mar 15, 2024
@eltigerchino eltigerchino changed the title Make wrangler optional when installing the cloudflare adapters Make wrangler optional when installing the Cloudflare adapters Mar 15, 2024
@dario-piotrowicz
Copy link
Contributor

dario-piotrowicz commented Mar 15, 2024

how are other frameworks handling this?

other frameworks usually have wrangler as a peer dependency, or only have the wrangler (peer) dependency in their Cloudflare specific adapter packages.

For example:


and is this even worth pursuing?

personally I would say that it might not be, since it only applies to your Cloudflare specific adapters (and if people use those they might as well get access to the proper platform variables)

(the only noticeable negative being stackblitz... but I am not sure how many developers use stackblitz with SvelteKit and Cloudflare, it doesn't feel to me like a common/core use case)

if you do want to reap out the wrangler dependency you could do what nitro/nuxt is doing, basically by not including wrangler as a peer dependency, and simply trying to dynamically import the getPlatformProxy and define a fallback behaviour if wrangler is not present/the import fails (for example by presenting an error to the user and returning a no-op version of the platform proxy)

@eltigerchino eltigerchino added this to the non-urgent milestone Mar 22, 2024
@eltigerchino
Copy link
Member Author

#12049 is a related issue. The adapter isn't able to build on Alpine.

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

Successfully merging a pull request may close this issue.

2 participants