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

Solid components break with imports in monorepo #7267

Closed
1 task
QuentinDutot opened this issue Jun 1, 2023 · 4 comments
Closed
1 task

Solid components break with imports in monorepo #7267

QuentinDutot opened this issue Jun 1, 2023 · 4 comments
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: solid Related to Solid (scope)

Comments

@QuentinDutot
Copy link

What version of astro are you using?

2.5.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Windows

What browser are you using?

Edge

Describe the Bug

In a monorepo with an astro app and a solidjs lib, importing a solidjs component from the lib break the component importing it.

Steps to reproduce in the reproducible example:

pnpm i => pnpm dev/start => open the browser

  • find the error in the console Uncaught (in promise) ReferenceError: React is not defined
  • clicking the button has not effect (should print hello world in the console)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-nj39de

Participation

  • I am willing to submit a pull request for this issue.
@bholmesdev bholmesdev added - P3: minor bug An edge case that only affects very specific usage (priority) pkg: solid Related to Solid (scope) labels Jun 12, 2023
@Brendonovich
Copy link

I've been experiencing this too.
I have @macrograph/web, an Astro app, and some packages like @macrograph/core and @macrograph/interface that export Solid components. Loading said components works fine, but when loading components from third party dependencies like @modular-forms/solid the React is not defined error is produced. (It doesn't happen during build since I client:only the Solid components).
Repo: https://github.com/Brendonovich/macrograph/tree/astro
Run the web app on the astro branch and it should happen.

@Brendonovich
Copy link

This may actually be a problem with Vite or vite-plugin-solid, as I've been experiencing this same problem when using standalone Vite + Solid

@Brendonovich
Copy link

Brendonovich commented Sep 19, 2023

Managed to fix this by adding a solid export condition to one of my packages. I'm not entirely sure how/why it works but vite-plugin-solid seems to look out for it according to this issue.
Here's the file
Here's a version of @QuentinDutot's stackblitz that works: https://stackblitz.com/edit/astro-nj39de-5bruya?file=lib-example%2Fpackage.json

@bluwy
Copy link
Member

bluwy commented Dec 26, 2023

Yeah this seems like a general publishing issue with Solidjs. Solid libraries need special care in Vite so that its internal JSX files are processed correctly. A solid export would be the way to fix it. There's a heuristic here: https://github.com/solidjs/vite-plugin-solid/blob/2b37a130f9f2cbece9e27bbdce6b67f16424866f/src/index.ts#L312-L319

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 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) pkg: solid Related to Solid (scope)
Projects
None yet
Development

No branches or pull requests

4 participants