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): fix regex for react imports #5274

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

rockwotj
Copy link
Contributor

Description

It does not handle regex in the form of import React, {useState} from 'react'

This causes files that use that pattern to have dual imports of react, which causes other issues.

Test cases below, I didn't see any existing tests for this plugin and it's out of scope of this PR to add them.

https://regexr.com/67cdh

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.

It does not handle regex in the form of `import React, {useState} from 'react'`
@antfu antfu changed the title Update regex for react imports fix(plugin-react): fix regex for react imports Oct 12, 2021
@patak-dev patak-dev merged commit 00b3e4f into vitejs:main Oct 12, 2021
@rockwotj rockwotj deleted the patch-1 branch October 12, 2021 21:16
@chase
Copy link

chase commented Oct 18, 2021

@antfu @patak-js Is there any chance we could get a release for @vitejs/plugin-react with this?

@rockwotj
Copy link
Contributor Author

@chase looks like 1.0.5 just got released.

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.

4 participants