Skip to content

[labs/react] __forwardedRef is being minified in prod builds #3211

Closed

Description

@justinfagnani

Which package(s) are affected?

React (@lit-labs/react)

Description

__forwardedRef matches our our Terser property name mangling config, so it's being minified. This is noticeable because the prod tests trigger a React warning that _$Gl isn't a valid attribute name, which is caused by us adding __forwardedRef to props here: https://github.com/lit/lit/blob/main/packages/labs/react/src/create-component.ts#L250

This should mean that user refs are broken, but we have a ref test, so we need to check our coverage here.

We can prevent the mangling either by adding '__forwardedRef' to our global reserved property names, or by setting Terser's keep_quoted option to true.

Reproduction

Run the react tests

Workaround

none

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

all

Browser/OS/Node environment

all

Activity

  1. moved this to 📋 Triaged in Lit Project Boardon Aug 12, 2022
  2. justinfagnani commented on Aug 15, 2022

    @justinfagnani
    CollaboratorAuthor

    Actually, it's not really a problem that __forwardedRef is minified. It's a property name entirely internal to the component. The only problem is that filtering it by string literal isn't working, so it's being passed to createElement().

  3. mjaggard commented on Aug 16, 2022

    @mjaggard

    Comment for better searchability because it took me quite a lot of hours to find this, only to find that this wasn't the cause of my issues - just updating Shoelace style caused this to be updated as well as cause the real problem.

    React
    Invalid attribute name: _$Gl

  4. Repository owner moved this from 📋 Triaged to ✅ Done in Lit Project Boardon Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions