-
Notifications
You must be signed in to change notification settings - Fork 13
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
Qwik and other JSX renderers in Astro #13
Comments
✨ Fix #13: Add include and exclude options to filter entrypoints.
For those reading this, you can use the exclude keyword with the integration in the astro config with the wildcard paths of other framework folders, and that should allow you to use Qwik and other frameworks for now. |
There seems to be a lot of "If-then-else" logic between this thread and this documentation involving multiple pieces: I don't think these instructions are accessible. What would feel accessible would be an examples directory with the different configs for the different scenarios. It would probably be of use for testing as well :D ETA - Sharing this feedback as a native english speaker with 5+ years polyglot experience(most in node and .net) that is struggling to grok what the paths are. |
Sounds like an awesome idea. Want to take a crack at it? |
I'd love to. flowchart LR
A["Add astro Qwik using cli `astro add` command"] --> B
B--"yes(react)"-->C
B--no-->D
B{Already rendering JSX components in another framework}
C["✔️ Do [x] with tsconfig
✔️ do [y] with react jsx files "]
D["✔️ Do [xx] with tsconfig"]
|
This is great! I would write down: add Using Qwik as your primary jsxImportSourceIf you intend to use Qwik the most add: "compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik"
} as your This is when you have more Qwik components on the page than other JSX frameworks. OR if it's the only JSX framework you are using alongside Qwik in your Astro project. If you have any React components, add:
If you have any solid components add:
If you have any preact components add:
When Qwik isn't the primary jsxImportSourceIf you don't intend to use Qwik as your primary This is when you may not have that many Qwik components compared to other JSX frameworks on the page. |
Cool. I'm going to take a crack at setting up these examples over the weekend. I'll touch base if I run into any issues. |
Sounds good! 👍 |
Hey @em-jones! Any progress? |
Maybe it should be by default in the example: /** @jsxImportSource @builder.io/qwik */ // necessary if you don't intend to use Qwik as your primary jsxImportSource
import { component$, useSignal } from "@builder.io/qwik";
export const Counter = component$(() => {
const counter = useSignal(0);
return <button onClick$={() => counter.value++}>My counter {counter.value}</button>;
}); I was close to give up about using Qwik with Astro because it didn't work out of the box and seem like I am the kind of person that doesn't read the whole README file... In reality, it is more that I am just looking at the different options and I cannot go deep in every documentation of each solution. |
I agree that this definitely needs to be included in the readme, preferably under the tsconfig section. I will do that now. If it was in the counter example my thoughts are it would likely cause more confusion as before, as it should only be added in the case of another JSX framework being used, and if this was copy pasted without a thought, consumers might skip the actual tsconfig setup, or think that this is the default way to add types to your Qwik components. All in all I am not happy with this solution that typescript provides us. It seems to be the same with other jsx frameworks, but hoping there is an alternative in the future. |
Okay, I've found that in most scenarios after the latest changes Qwik should work alongside any other JSX framework. The edge cases I've found seem to be caused by the other renderers. If you come across any issues, I suggest putting the Qwik integration first in your integrations: [qwik(), react({ include: ["**/react/*"] })] You should not need to use an |
There is currently an issue using Qwik alongside other JSX-based framework integrations in Astro. My understanding is that the user needs to change their file structure and astro config for this to work.
The problem, is that the
renderToStaticMarkup
function that Astro provides, will also try to read / render other JSX components.For example, if we add a React component to
index.astro
, the@qwikdev/astro
integration will log out the following fromserver.ts
If we have it return nothing when it is not a Qwik component like this:
Then it will still error out, as
renderFrameworkComponent
(being used internally by Astro), tries to look for the React client entrypoint.My understanding, is that we need to add an
include
option for consumers in theastro.config.mjs
, which I then think would need to be provided to qwikVite? or a new setting in the plugin?This is where I'm a bit lost,
https://docs.astro.build/en/guides/upgrade-to/v3/#what-should-i-do-24
I saw this in the Solid integration:
And then in their vite plugin:
Which uses this:
https://github.com/micromatch/picomatch
The text was updated successfully, but these errors were encountered: