Skip to content

[Bug]: TSRX v2 | static hoisting improvements #1214

Description

@mizulu

Issue Category

Other

Bug Description

1. continuous static elements can be hoisted into a single variable

instead of producing a variable per element

const StatusBadge__static1 = <div> 123 </div>;
const StatusBadge__static2 = <div> 123 </div>;
const StatusBadge__static3 = <div> 123 </div>;
const StatusBadge__static4 = <div> 123 </div>;
const StatusBadge__static5 = <div> 123 </div>;
const StatusBadge__static6 = <div> 123 </div>;
const StatusBadge__static7 = <div> 123 </div>;

it can produce

const StatusBadge__static1 = <><div> 123 </div>
<div> 123 </div>
<div> 123 </div>
 <div> 123 </div>
<div> 123 </div>
<div> 123 </div>
<div> 123 </div></>

2. static element inside expression can also be hoisted.

currently the 1st div is hoisted, but the 2nd stays as is in the compiled output

<>
<div> 123 </div>
{<div> 123 </div>}
</>
Image

Reproduction Steps

playground

Environment

Additional Context

No response

Checklist

  • I've searched for existing issues
  • I'm willing to help implement a fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions