-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Improved JSX framework detection #382
Conversation
This improves the JSX detection and adds a bunch of test. The following is improved: * If an error throws because of a coding mistake, those errors will be reported. * We properly detect class components for both Preact and React. We don't have to "try to render" these. It's still possible that error messages might be obscured in this scenario: A Preact function component that uses hooks (or another preact specific feature) that has a coding mistake. The React renderer might throw when it uses the Preact hook. That error will be reported rather than the real coding mistake. This is because we can't distinguish between errors that are due to the wrong framework and errors that the user caused. I might reach out to the Preact community and see if they can think of a better solution to this problem. This will come up when other JSX based frameworks have renderers. I still think that having multiple frameworks in the same project is a feature worth trying to preserve.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/astro-www/Hkb3foCHdsCNpWcTa3vR1LyJM6J5 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
+100 to this. And I think Preact and React are very likely cohabitants of the same project, especially if someone is trying to migrate from React to Preact, for example. |
+1 as well. I still want to have a convo about the best way to deliver on that though. (Maybe |
Realized I can probably move the try/catch out of the renderer, simplifying it's signature. So I want to make that change before merging this. |
* Improved JSX framework detection This improves the JSX detection and adds a bunch of test. The following is improved: * If an error throws because of a coding mistake, those errors will be reported. * We properly detect class components for both Preact and React. We don't have to "try to render" these. It's still possible that error messages might be obscured in this scenario: A Preact function component that uses hooks (or another preact specific feature) that has a coding mistake. The React renderer might throw when it uses the Preact hook. That error will be reported rather than the real coding mistake. This is because we can't distinguish between errors that are due to the wrong framework and errors that the user caused. I might reach out to the Preact community and see if they can think of a better solution to this problem. This will come up when other JSX based frameworks have renderers. I still think that having multiple frameworks in the same project is a feature worth trying to preserve. * Move try/catch into the __astro_component
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Changes
This improves the JSX detection and adds a bunch of test. The following is improved:
It's still possible that error messages might be obscured in this scenario:
A Preact function component that uses hooks (or another preact specific feature) that has a coding mistake. The React renderer might throw when it uses the Preact hook. That error will be reported rather than the real coding mistake.
This is because we can't distinguish between errors that are due to the wrong framework and errors that the user caused.
I might reach out to the Preact community and see if they can think of a better solution to this problem. This will come up when other JSX based frameworks have renderers. I still think that having multiple frameworks in the same project is a feature worth trying to preserve.
Testing
Docs
N/A