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

split option for adapter-cloudflare #9617

Closed
nCrafts opened this issue Apr 7, 2023 · 8 comments
Closed

split option for adapter-cloudflare #9617

nCrafts opened this issue Apr 7, 2023 · 8 comments

Comments

@nCrafts
Copy link

nCrafts commented Apr 7, 2023

Describe the problem

So it seems that sveltekit deploys the whole app (minus the static parts) as a single worker.js file. Cloudflare has a limit of 1mb for this file.

How does one structure an application that doesn't exceed 1mb in total?

Example, I am using markdown to store content in my project, which is imported using this code in +pager.server.ts:

const modules = import.meta.glob('../../markdown/**/*.md')

Unless I am doing something wrong it seems that the single worker.js file now includes all of the markdown files?

Related: #2963

Describe the proposed solution

I don't really know. Maybe a way for the adapter to scale to something larger?

Alternatives considered

I've looked at Vercel but I don't like the pricing, and cloudflare seems to offer more features.

Importance

i cannot use SvelteKit without it

Additional Information

No response

@benmccann
Copy link
Member

benmccann commented Apr 7, 2023

Vercel has a split option: https://kit.svelte.dev/docs/adapter-vercel#deployment-configuration. This sounds like a request to have that option in adapter-cloudflare as well

#2963 looks quite related

@benmccann benmccann changed the title adapter-cloudflare doesn't seem feasible for large projects feat: split option for adapter-cloudflare Apr 7, 2023
@benmccann benmccann added the feature / enhancement New feature or request label Apr 7, 2023
@benmccann benmccann changed the title feat: split option for adapter-cloudflare split option for adapter-cloudflare Apr 7, 2023
@nCrafts
Copy link
Author

nCrafts commented Apr 7, 2023

I believe the Cloudflare allows 5mb on the paid plans, which gives some more room. Still, being able to split the app would be amazing.

I am not sure if it’s possible though. It seems that Cloudflare expects one _worker.js file:
https://developers.cloud flare.com/pages/how-to/refactor-a-worker-to-pages-functions/

@nCrafts nCrafts closed this as completed Apr 7, 2023
@nCrafts nCrafts reopened this Apr 7, 2023
@benmccann
Copy link
Member

@jrf0110 do you know if this feature is possible to implement on Cloudflare Pages?

@markjaquith
Copy link
Contributor

Note that these limits (1MB free, 5MB paid) are after gzip compression. My SvelteKit app produces a 1.75MB _worker.js file, but it gzips down to 405KB. If I do some JS minification before gzipping, I can get it slightly smaller... 376KB. There might be some more that SvelteKit can squeeze in with minification.

I don't think it's possible to do auto splitting yet (see this ticket), but you can petition them on a case-by-case basis to raise the limit for you: https://forms.gle/ukpeZVLWLnKeixDu7

@nCrafts
Copy link
Author

nCrafts commented Apr 8, 2023

Another thing to add, and maybe this is something to control within Sveltekit: the content of my pre-rendered routes is also being added to the _worker.js file.

Example, if I add a .md page to my route, while enabling pre-rendering, the content of this .md file ends up in the _worker.js file, even though the page is pre-rendered.

Beyond the file size itself having a large _worker.js file will increase the worker startup time. Having all the raw text content of the website load on every worker invocation is not very effective.

Any advice would be welcome.

@jrf0110
Copy link
Contributor

jrf0110 commented Apr 10, 2023

@jrf0110 do you know if this feature is possible to implement on Cloudflare Pages?

Soon :) cloudflare/workers-sdk#2769

@bgronek
Copy link

bgronek commented Aug 3, 2023

Looks like cloudflare/workers-sdk#2769 has been merged and deployed. So does this now need to be incorporated into the adapter?

@eltigerchino
Copy link
Member

closing in favour of #2963

@eltigerchino eltigerchino closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants