adapters icon indicating copy to clipboard operation
adapters copied to clipboard

Cloudflare build error with `astro/lit` SSR

Open tkd-yas opened this issue 1 year ago • 4 comments

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"

full logs

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.

tkd-yas avatar May 16 '24 00:05 tkd-yas

Reproduce process:

  1. check out https://github.com/tkd-yas/astro-lit-cloudflare.git
  2. run yarn run build
  3. see generated dist/_worker.js/renderers.mjs

tkd-yas avatar May 16 '24 00:05 tkd-yas

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 avatar May 16 '24 16:05 matthewp

@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? 🤔

alexanderniebuhr avatar May 16 '24 16:05 alexanderniebuhr

It may not need to be external any more. That's like pretty old code.

matthewp avatar May 16 '24 17:05 matthewp

This should be fixed in the v11 release, which will be published later today to npm.

alexanderniebuhr avatar Jun 22 '24 09:06 alexanderniebuhr

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

Full log

a-xmd avatar Aug 16 '24 11:08 a-xmd