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

Implement the new JSX transform function #14

Merged
merged 7 commits into from
Jul 23, 2023

Conversation

bqqbarbhg
Copy link
Contributor

@bqqbarbhg bqqbarbhg commented Jul 22, 2023

Implement the new JSX transform function in kaiku. This allows kaiku to be used without having to import or specify the JSX factory function h().

The jsx() function differs from the legacy h() JSX factory in signature and thus needs specific support. I opted to implement jsx() directly instead of wrapping h() as that would lead into double copying of props which would hurt performance. The size overhead of this approach is 80 bytes in the final gzipped bundle:

baseline raw   6,98 KB (7 150 bytes)
jsx() raw      7,21 KB (7 387 bytes)
baseline gzip  2,91 KB (2 983 bytes)
jsx() gzip     2,99 KB (3 063 bytes)

The cost in size by keeping both h() and jsx() allows users to use either JSX transform without any additional configuration, which in my user-focused opinion seems like a fair tradeoff.

For further development adding key to element descriptors directly and allowing children to be a single element value would allow us to use props directly without copying in the descriptor instances which would reduce a ton of unnecessary allocations and object copies during component rendering.

@bqqbarbhg bqqbarbhg marked this pull request as draft July 22, 2023 15:45
@bqqbarbhg bqqbarbhg marked this pull request as ready for review July 22, 2023 18:35
@oamaok oamaok merged commit e914368 into oamaok:main Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants