boggin
boggin
Explore posts from servers
CDCloudflare Developers
Created by boggin on 10/30/2024 in #pages-help
Some help with wrangler pages dev with vite?
I can't seem to find the commands and config to run my sveltekit app in dev environment with local or remote bindings.
8 replies
CDCloudflare Developers
Created by boggin on 7/22/2024 in #pages-help
dep problems sveltekit cloudflare-adapter when building
I can't build because of adapter-cloudflare's deps being wrong node modules? but the error must come from the adapter.... When I run build, it spits out many errors like:
✘ [ERROR] Could not resolve "url"

node_modules/youch/src/Youch.js:16:34:
16 │ const { fileURLToPath } = require('url')
╵ ~~~~~

Cannot use "url" when deploying to Cloudflare.
✘ [ERROR] Could not resolve "url"

node_modules/youch/src/Youch.js:16:34:
16 │ const { fileURLToPath } = require('url')
╵ ~~~~~

Cannot use "url" when deploying to Cloudflare.
from the deps like youch. When I npm ls youch, it spits out:
└─┬ @sveltejs/[email protected]
└─┬ @sveltejs/[email protected]
So the adapter is throwing the error of an incompatibility essentially of its own dependencies.... [email protected]
3 replies
CDCloudflare Developers
Created by boggin on 1/9/2024 in #general-help
Wasm problem with Sveltekit, Cloudflare Pages and Resvg.
I'm trying to implement dynamic opengraph images, and so far the most promising solution has been satori + Resvg on a server endpoint (turns into a cloudflare pages function). It works beautifully everywhere except deployed on Cloudflare. "CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder" I found this "workaround" which does not seem to work: https://github.com/cloudflare/workers-sdk/issues/1366 which defines a wasm Memory to a 512 pagesize to be able to work on Cloudflare.
The wasm package I'm trying to use is Resvg. which I import via fetch using Vite's ..wasm?url directive because Vite doesn't support ESM wasm modules especially in SSR.
I tried using vite plugins for directly importing wasm modules (like vite-plugin-wasm and also mentioned here https://github.com/vitejs/vite/issues/8882) with no success because then it throws a cannot find module 'wbg' error. I understand there are tons of factors frameworks and tools associated with this but if anyone can help me at all tha'd be amazing
37 replies
DTDrizzle Team
Created by boggin on 12/1/2023 in #help
Drizzle + Sveltekit + Cloudflare + Supabase cannot get to work.
If I use Drizzle's docs, like :
import { Pool } from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
I get node module resolution errors like:
node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
node_modules/pg/lib/connection.js:3:18: ERROR: Could not resolve "net"
node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
node_modules/pg/lib/connection.js:3:18: ERROR: Could not resolve "net"
If I follow Supabase's docs on connecting with drizzle, like:
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
I get node module errors like:
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
Cloudflare definitely says to use the newer colon-delimited name like node:stream, and I have followed all of Cloudflare's instructions for node compatibility, but these errors persist. Anyone have advice?
6 replies
CDCloudflare Developers
Created by boggin on 12/1/2023 in #pages-help
sveltekit and node errors on build
Trying to use Sveltekit, with Supabase and Drizzle ORM preferably. - I've put nodejs_compat in the compatibility flags in both preview and production - Node version is 18 (set via environment variable) - I'm using build engine 1 - Using Sveltekit. - my postgres client instantiation is in $lib/server/ which I'm told makes it definitely server only - Using the cloudflare sveltekit adapter.
node_modules/postgres/cf/polyfills.js:1:29: ERROR: Could not resolve "node:events"
node_modules/postgres/cf/polyfills.js:2:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/polyfills.js:1:29: ERROR: Could not resolve "node:events"
node_modules/postgres/cf/polyfills.js:2:23: ERROR: Could not resolve "node:buffer"
Cant seem to find anything online why it'd be throwing this.
7 replies
CDCloudflare Developers
Created by boggin on 7/17/2023 in #pages-help
KV access in a Sveltekit dev environment
Hi there. Appreciate the help in advance. I'm having the worst time trying to figure out if its possible to use a KV store in a dev environment. I'd like to use a full-on test KV where I can save keys and such. It seems everything that I've tried, platform.env on a server endpoint on my Sveltekit app is only available deployed in production. I'm using npx wrangler pages dev .svelte-kit/cloudflare once built, with
toml
kv_namespaces = [
{ binding = "test", id = "76n8s756fi7sd56fn", preview_id = "7sdtn6fi6s5dbf76s5ndf" },
]
toml
kv_namespaces = [
{ binding = "test", id = "76n8s756fi7sd56fn", preview_id = "7sdtn6fi6s5dbf76s5ndf" },
]
in my wrangler.toml. (random hash ids for example's sake) console logging platform.env is always undefined though the wrangler pages dev. I've done wrangler kv:namespace create test and used preview_id just as the docs say, but I just can never access platform Is it possible to have full KV functionality in a local dev environment? And if so, I don't understand how platform connects using Sveltekit.
7 replies