Cloudflare build error with `astro/lit` SSR
Astro Info
Astro v4.8.2
Node v20.4.0
System macOS (arm64)
Package Manager unknown
Output server
Adapter @astrojs/cloudflare
Integrations @astrojs/lit
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I faced build error on Cloudflare pages. The target app is Astro integrated lit.
Error Message:
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "@astrojs/lit/server.js".
imported from "renderers.mjs"
Cause is generated renderers.mjs includes unexists import.
import _renderer0 from '@astrojs/lit/server.js';
i think avoid this external file load. anyone knows work around?
What's the expected result?
success buid on Cloudflare Pages.
Link to Minimal Reproducible Example
https://github.com/tkd-yas/astro-lit-cloudflare
Participation
- [ ] I am willing to submit a pull request for this issue.
Reproduce process:
- check out https://github.com/tkd-yas/astro-lit-cloudflare.git
- run
yarn run build - see generated
dist/_worker.js/renderers.mjs
I don't know if Lit works on cloudflare (it depended on Node APIs last I remember). Transfering to the adapters repo for triage.
@matthewp Using Node APIs might be a blocker, but the first blocker we face here is that we set it to be externalized: https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts#L17
As long as it is externalized we can't use it with Cloudflare, I think my initially question is, could we not have that external setting in the package? 🤔
It may not need to be external any more. That's like pretty old code.
This should be fixed in the v11 release, which will be published later today to npm.
Was this fixed in he v11 release? I'm still getting:
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "@astrojs/lit/server.js". imported from "renderers.mjs"
Minimal Reproducible Example: https://github.com/a-xmd/astro-lit-cloudflare-repro