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

Unwrap arrow function IIFEs in component props #272

Merged
merged 4 commits into from
Sep 18, 2023

Conversation

intrnl
Copy link
Contributor

@intrnl intrnl commented Aug 21, 2023

As per pull request title, unwraps arrow function IIFEs if they are directly used within a component prop.

the following <Show /> pattern can be quite common, and this saves up some of the bytes incurred by it

<Show
  when={(() => {
    const val = value();
    if ("key" in val) {
      return val;
    }
  })()}
>
  {(val) => (
    <>
      ...
    </>
  )}
</Show>

@intrnl
Copy link
Contributor Author

intrnl commented Aug 21, 2023

this usage should be a non-issue as arrow functions this has already been handled by the plugin, but we can make an additional test case for this

@ryansolid
Copy link
Owner

I like this. It does add complication to the compiler but it is definitely the type of thing we can do. I'm trying to think of anywhere this falls down but I don't think so.

@ryansolid ryansolid merged commit d96e0fc into ryansolid:main Sep 18, 2023
1 check passed
@intrnl intrnl deleted the feat/unwrap-arrow-fn branch September 18, 2023 23:17
ryansolid pushed a commit that referenced this pull request Oct 4, 2023
* chore: add test for iife in props

* feat: unwrap arrow iife in props

* chore: add case for iife with no body

* chore: add case for this usage in iife prop
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