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

fix(plugin-react): React is not defined when component name is lowercase #6838

Merged

Conversation

xyl66
Copy link
Contributor

@xyl66 xyl66 commented Feb 10, 2022

Description

Bug describe and reproduce: #6537

This PR is fix React is not defined on production。
When the react variables (such as React__default) of the code in our third-party dependencies are converted to React, and the component name is lowercase, it is not converted to jsx, which will cause React to be undefined after restoring the code.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

…wercase

When the react variables (such as React__default) of the code in our third-party dependencies are converted to React, and the component name is lowercase, it is not converted to jsx, which will cause React to be undefined after restoring the code.
@Niputi
Copy link
Contributor

Niputi commented Feb 10, 2022

could you include a test?

@xyl66 xyl66 force-pushed the fix-plugin-react-restore-jsx-react-not-defined branch from 3da9a28 to 98d55e6 Compare February 10, 2022 10:44
@aleclarson aleclarson force-pushed the fix-plugin-react-restore-jsx-react-not-defined branch from c913bc1 to a09c8aa Compare February 10, 2022 20:50
@aleclarson aleclarson force-pushed the fix-plugin-react-restore-jsx-react-not-defined branch from a09c8aa to 37ca8f6 Compare February 10, 2022 21:03
@alexandertrefz
Copy link

alexandertrefz commented Apr 20, 2022

@patak-dev Would be great if this could get merged, many people seem to run into this issue, #7640 for example.

@patak-dev patak-dev changed the title fix(plugin-react): fix React is not defined when component name is lo… fix(plugin-react): React is not defined when component name is lowercase May 2, 2022
@patak-dev patak-dev merged commit bf40e5c into vitejs:main May 2, 2022
@sapphi-red sapphi-red mentioned this pull request May 6, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants