Closed jmho closed 3 months ago
@jmho thank you for submitting this issue. Cloudflare doesn't support node apis. The package/library firebase-admin
uses node's stream
.
Cloudflare has a nodejs_compat
mode, which allows to use some node apis, but they need to be imported with the node:*
prefix syntax. (https://developers.cloudflare.com/workers/runtime-apis/nodejs/#enable-nodejs-with-pages-functions)
I would suggest checking in with the authors of that package, if they support the node:*
import syntax.
@alexanderniebuhr Thanks for the prompt response. That makes a lot of sense! I'll check in with them.
In the mean time, do you think it would make sense for me to open a PR to update the astro docs to be more explicit about this? I feel like this is a pretty major limitation on deciding to deploy with Cloudflare, as this affects not just projects using firebase but the usage of packages that don't use node:* import syntax out of the box.
I was thinking adding a blurb to the Troubleshooting section mentioning the build failing and the potential reason why could be helpful for future devs. I was also thinking editing the main docs for the Cloudflare adapter so that this limitation is more apparent when deploying with SSR could also be useful!
What do you think?
I can't really imagine how that would look like. I would suggest reaching out with that question to the Docs
channel on our Discord. In general we don't suggest opening directly a PR to the docs repo, because it might get rejected and then you did work for nothing, so it's worth to check in on Discord first.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro fails to create a production build when the project uses the Cloudflare adapter and imports firebase-admin into a server endpoint. It appears that the frontend successfully builds but the server fails to build and the following stack trace is produced:
The minimum reproducible steps are as follows:
firebase
andfirebase-admin
import { app } from '../../../firebase/server';
npm run build
What's the expected result?
The server build shouldn't throw any errors. When tested with the NodeJS adapter, this was the case.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-1dhscj?file=src%2Fpages%2Fapi%2Ffriends%2Findex.ts
Participation