Rastislav₡ore
Rastislav₡ore
CDCloudflare Developers
Created by Rastislav₡ore on 11/29/2024 in #pages-help
Deployment Issues on Cloudflare Pages with SvelteKit 5
We are encountering issues while deploying two separate SvelteKit 5 projects to Cloudflare Pages. The build process fails with errors related to resolving component paths or modules. Here are the details of the issues: 1. Project 1: DApp SvelteKit Boilerplate
Error:
[vite-plugin-pwa:build] Could not resolve "./icon" from "src/lib/components/index.ts"

[vite-plugin-pwa:build] Could not resolve "./icon" from "src/lib/components/index.ts"

The index.ts exports components from specific folders, such as export { Icon } from './icon';, but the PWA plugin cannot resolve the path despite no issues in local development. 2. Project 2: PayTo
Error:
Could not resolve "./Toast.svelte" from "src/lib/components/toast/index.ts"

Could not resolve "./Toast.svelte" from "src/lib/components/toast/index.ts"

Similar to the first project, the index.ts files structure components, and the issue arises when the PWA plugin fails to resolve paths during the Cloudflare build process. Both projects work correctly in local environments, including full SSR builds, but they consistently fail on Cloudflare Pages. Key configurations such as vite.config.ts, TypeScript type definitions, and component structures have been verified, and Cloudflare-specific configurations (e.g., wrangler.toml) align with the projects’ requirements. Questions for the Community: 1. Are there known limitations or nuances with the vite-plugin-pwa or Rollup on Cloudflare Pages that could be causing these resolution issues? 2. Could the problem be related to the wrangler.toml setup, Cloudflare's filesystem structure, or case sensitivity in component folder names? 3. Is there a recommended debugging approach to further isolate issues specific to Cloudflare’s environment? Any insights or similar experiences would be greatly appreciated!
2 replies
CDCloudflare Developers
Created by Rastislav₡ore on 9/16/2024 in #pages-help
Compatibility flags for PosgreSQL
I am trying to build and deploy SvelteKit page with enabled flags: nodejs_compat or nodejs_compat_v2 https://developers.cloudflare.com/workers/configuration/compatibility-dates/#compatibility-flags I am using Drizzle connector, but seems I run always into node compatibility issues, which are present on native postgres.js also. Connectors are present in Hyperdrive: https://developers.cloudflare.com/hyperdrive/configuration/connect-to-postgres/#supported-drivers Source code: https://github.com/bchainhub/dapp-sveltekit-boilerplate/tree/update/contrib-13 My questions: Q1: Do I need to upgrade to paid plan for Node.js features support? (I am aware of Hyperdrive included in Paid plan) Q2: What should I change to make Node.js API working on my Pages deployment? Some of errors I am getting while deployment:
✘ [ERROR] Could not resolve "node:stream"
node_modules/postgres/cf/src/large.js:1:import Stream from 'node:stream'
The package "node:stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

error during build:
Error: Build failed with 8 errors:
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/src/bytes.js:1:23: ERROR: Could not resolve "node:buffer"
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"
✘ [ERROR] Could not resolve "node:stream"
node_modules/postgres/cf/src/large.js:1:import Stream from 'node:stream'
The package "node:stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

error during build:
Error: Build failed with 8 errors:
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/src/bytes.js:1:23: ERROR: Could not resolve "node:buffer"
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"
- page: core-dapp.pages.dev - deployment: 580ce1e I checked the examples here also: https://developers.cloudflare.com/hyperdrive/examples/
28 replies