Open
Description
We're using the pg
package in a project. Recently, we get this error during build process:
error [vite]: Rollup failed to resolve import "cloudflare:sockets" from "/node_modules/pg-cloudflare/dist/index.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
Error: [vite]: Rollup failed to resolve import "cloudflare:sockets" from "/node_modules/pg-cloudflare/dist/index.js".
The thing is, we are not using cloudflare or cloudflare workers at all. I saw that the pg-cloudflare
package is in the optional dependencies of the pg
package. For whatever reason, node installs all optional dependencies by default. So I tried installing the packages without the optional dependencies.
But now there is this error:
✘ [ERROR] Could not resolve "pg-cloudflare"
node_modules/pg/lib/stream.js:10:41:
10 │ const { CloudflareSocket } = require('pg-cloudflare')
╵ ~~~~~~~~~~~~~~~
You can mark the path "pg-cloudflare" as external to exclude it from the bundle, which will remove
this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
What did I do wrong?
Metadata
Metadata
Assignees
Labels
No labels