`unstable_dev` with Cloudflare Pages

is there any way to use unstable_dev with Cloudflare Pages yet? when testing a svelte-kit build, i tried
siteServer = await unstable_dev(path.join(SITE_DIR, ".svelte-kit", "cloudflare", "_worker.js"), {
experimental: { enablePagesAssetsServiceBinding: {
directory: path.join(SITE_DIR, ".svelte-kit", "cloudflare"),
} },
siteServer = await unstable_dev(path.join(SITE_DIR, ".svelte-kit", "cloudflare", "_worker.js"), {
experimental: { enablePagesAssetsServiceBinding: {
directory: path.join(SITE_DIR, ".svelte-kit", "cloudflare"),
} },
the worker runs, but somehow it can't find the assets
7 Replies
iceghost
iceghost11mo ago
pnpm wrangler pages dev is broken as hell too, why pnpm wrangler pages dev .svelte-kit/cloudflare can find the functions but when inside .svelte-kit or cloudflare, running it again with pnpm wrangler pages dev cloudflare or . can't find the functions (No functions. Shimming...)
ajgeiss0702
ajgeiss070211mo ago
If you’re using sveltekit, I’d recommend using its built-in dev environment (pnpm dev)
iceghost
iceghost11mo ago
umm, i'm running those generated functions, so i'm not sure what you meant here Then there would be no platform property, no? i would like to access Cloudflare's bindings inside my load functions, or server-side in general. pnpm dev would not work because nothing is running workerd, so I wanted to build the project and test it with wrangler, just like the docs suggests:
platform.env is only available in the production build. Use wrangler to test it locally.
platform.env is only available in the production build. Use wrangler to test it locally.
basically, two things broke: 1. unstable_dev to preview a built-with-sveltekit output doesn't work 2. wrangler pages dev to preview a built-with-sveltekit output doesn't work i'm not actively working on this anymore, but that is my experience with local Cloudflare Pages
ajgeiss0702
ajgeiss070211mo ago
I use the miniflare api to set the bindings in the hooks file
iceghost
iceghost11mo ago
Then miniflare v2 it is. I'm figuring out how to use miniflare v3 here, unfortunately
ajgeiss0702
ajgeiss070211mo ago
i havent migrated yet, but from what i've seen the api changes are minimal? and it v3 now uses workerd BTS after looking into it further, it looks like miniflare v3 removed getBindings so it's no longer possible to do that. So im stuck on miniflare v2 until either getBindings is added back, or another solution is found
ajgeiss0702
ajgeiss070211mo ago
I guess this might be the issue to pay attention to https://github.com/cloudflare/miniflare/issues/585
GitHub
Missing migration guide for usage of getBindings() · Issue #585 ·...
Previously in V2, the getBindings() method was useful for working with SvelteKit and KV, D1, etc. locally. However, this method has been removed without new recommendations for retrieving the bindi...
Want results from more Discord servers?
Add your server
More Posts