Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lit + SSR: unable to resolve a valid export #8216

Closed
1 task
JosefJezek opened this issue Aug 24, 2023 · 2 comments
Closed
1 task

Lit + SSR: unable to resolve a valid export #8216

JosefJezek opened this issue Aug 24, 2023 · 2 comments
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) ecosystem: external External library doesn't work pkg: lit Related to Lit (scope)

Comments

@JosefJezek
Copy link

Astro info

Astro version            v2.10.14
Package manager          npm
Platform                 linux
Architecture             x64
Adapter                  Couldn't determine.
Integrations             @astrojs/lit

What browser are you using?

Chrome

Describe the Bug

error   Unable to resolve a valid export for "md-outlined-button"! Please open an issue at https://astro.build/issues!
  File:
    /home/projects/github-uiraud/node_modules/astro/dist/runtime/server/hydration.js:83:11
  Code:
    82 |     children: "",
    > 83 |     props: {
         |           ^
      84 |       // This is for HMR, probably can avoid it in prod
      85 |       uid: astroId
      86 |     }
  Stacktrace:
Error: Unable to resolve a valid export for "md-outlined-button"! Please open an issue at https://astro.build/issues!
    at Module.generateHydrateScript (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/hydration.js:83:11)
    at renderFrameworkComponent (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/component.js:267:46)
    at async Module.renderComponent (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/component.js:351:10)
    at async Module.renderChild (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/any.js:14:11)

What's the expected result?

MD components are working with Next.js SSR, see material-components/material-web#4245 (comment)

Please improve support for Lit.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-uiraud?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 24, 2023
@natemoo-re natemoo-re added pkg: lit Related to Lit (scope) ecosystem: external External library doesn't work - P3: minor bug An edge case that only affects very specific usage (priority) labels Aug 31, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 31, 2023
@marcmalerei
Copy link

My mistake. Instead of writing the name of the component in upper camelcase, i

Astro info

Astro version            v2.10.14
Package manager          npm
Platform                 linux
Architecture             x64
Adapter                  Couldn't determine.
Integrations             @astrojs/lit

What browser are you using?

Chrome

Describe the Bug

error   Unable to resolve a valid export for "md-outlined-button"! Please open an issue at https://astro.build/issues!
  File:
    /home/projects/github-uiraud/node_modules/astro/dist/runtime/server/hydration.js:83:11
  Code:
    82 |     children: "",
    > 83 |     props: {
         |           ^
      84 |       // This is for HMR, probably can avoid it in prod
      85 |       uid: astroId
      86 |     }
  Stacktrace:
Error: Unable to resolve a valid export for "md-outlined-button"! Please open an issue at https://astro.build/issues!
    at Module.generateHydrateScript (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/hydration.js:83:11)
    at renderFrameworkComponent (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/component.js:267:46)
    at async Module.renderComponent (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/component.js:351:10)
    at async Module.renderChild (/home/projects/github-uiraud/node_modules/astro/dist/runtime/server/render/any.js:14:11)

What's the expected result?

MD components are working with Next.js SSR, see material-components/material-web#4245 (comment)

Please improve support for Lit.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-uiraud?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

I had a similar Error. I made the mistake to write <my-element/> instead <MyElement/> in the index.astro file.

@bluwy
Copy link
Member

bluwy commented Oct 13, 2023

Astro's island component detection works through direct imports of the framework component:

A client directive can only be used on a UI framework component that is directly imported into a .astro component.

In this case, you're importing import '@material/web/button/outlined-button'; and then using it <md-outlined-button client:load>Hello World</md-outlined-button>. Astro can't know those are related in order to server-side render and hydrate it.

You can fix it by writing it this way:

---
import { MdOutlinedButton } from '@material/web/button/outlined-button';
---

<MdOutlinedButton client:load>Hello World</MdOutlinedButton>

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) ecosystem: external External library doesn't work pkg: lit Related to Lit (scope)
Projects
None yet
Development

No branches or pull requests

4 participants