-
-
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
Improve Astro JSX rendering #10473
Improve Astro JSX rendering #10473
Conversation
🦋 Changeset detectedLatest commit: 08e9949 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (nonAstroPageNeedsHeadInjection(Component)) { | ||
if (isPage && !result.partial && nonAstroPageNeedsHeadInjection(Component)) { |
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.
We now only try to render the head if this component is a page and is non-partial. Otherwise there's chance we could render a component but not use it (with how the new renderJSX
flow works)
!bench render EDIT: It doesn't look like there's much gain |
This comment was marked as resolved.
This comment was marked as resolved.
Performance-wise, maybe not, but memory-wise, maybe yes. We don't construct a |
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.
Less code is the best code! 💪
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.
Looks fine to me!
Changes
Fixes #10158
This fix requires some context, so here it is 😄:
When rendering JSX nodes, there's currently a problem where it can call
renderComponentToString
to render React/Vue/MDX component from JSX nodes, but it can also render JSX nodes again if it hits theastro:jsx
renderer (for MDX). Creating a loop.Before
The solution to this problem is using "Skips" to make sure this order is ran (Worst case):
(I don't know why no4 and no5 repeated. Perhaps a typo in the logic?)
After
We use a single Symbol only to check if it had tried to render with React/Vue/MDX renderers. New order (Worst case):
This refactor allows us to simplify the skips logic, and remove the console filter as we no longer unconditionally render
vnode.type
.renderComponentToString
will check for it first.Testing
Existing tests should pass. Also tested the repro manually from #10158 (didn't add test because Svelte 5 is still experimental and hard to setup test). Also tested repro from #4894.
Docs
n/a. bug fix.