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

refactor!: migrate plugin-react-refresh to plugin-react #3588

Merged
merged 76 commits into from
Sep 17, 2021

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented May 29, 2021

⚠️ Do not squash (to preserve commit history)

Description

Once this plugin is released, @vitejs/plugin-react-refresh should be deprecated.

This plugin will do the following:

Status

Almost ready to ship 🚢

Remaining questions

  1. Should jsxRuntime: "automatic" be the default?
  2. What should be done with plugin-react/CHANGELOG.md?

Todo

  • Fix lint problems
  • Migrate to TypeScript
  • Copy over unit tests from here
  • Setup a test suite in ./packages/playground (in progress by @pengx17)

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.

@Shinigami92
Copy link
Member

I added now the new label plugin: react

@antfu antfu changed the title Add plugin-react refactor!: migrate plugin-react-refresh to plugin-react May 30, 2021
@kjeske
Copy link

kjeske commented Jun 10, 2021

Thanks @aleclarson for your work in that PR, it's something I'm really looking forward to :) What is the status of the works?

@antfu antfu marked this pull request as draft June 11, 2021 07:51
@aleclarson
Copy link
Member Author

aleclarson commented Jun 11, 2021

@kjeske It should be ready for use. To get this merged, someone needs to setup some tests in ./packages/playground, but I don't know when I'll get around to doing that. I'm hoping a community member picks up the slack there, since I've done so much work already. :)

Specifically, playground/react should be migrated to use @vitejs/plugin-react instead. We don't need the esbuild.jsxInject configuration anymore. We also need to test the jsxRuntime: "automatic" option, but that probably needs its own playground/react-jsx-runtime folder.

@Shinigami92
Copy link
Member

packages/plugin-react/CHANGELOG.md may need to be resetted to v1.0.0 🤔

Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getJSXNode, getJSXName, getJSXProps and getJSXChildren feels a bit to wide open 🤔
Maybe they can benefit from using generic arguments

packages/plugin-react/src/fast-refresh.ts Show resolved Hide resolved
packages/plugin-react/src/fast-refresh.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated Show resolved Hide resolved
@aleclarson
Copy link
Member Author

It might be better to copy over the unit tests from here instead of trying to perfect the types. I don't expect much future development of babel-restore-jsx to take place, so I don't think the types are worth the squeeze. I suppose I should've mentioned this before, but I didn't expect you to go the extra mile. :)

@Shinigami92
Copy link
Member

Okay, so I'm glad that I just was bored yesterday 😄
But you should look at least into my first two review comments for packages/plugin-react/src/fast-refresh.ts

@kjeske
Copy link

kjeske commented Jun 24, 2021

What's missing now in this PR to be completed?

@aleclarson
Copy link
Member Author

@kjeske See the todos in the OP. Feel free to open a PR targeting this one if you decide to help out 😃

@aleclarson aleclarson merged commit 825bdf4 into vitejs:plugin-react Sep 17, 2021
@aleclarson aleclarson deleted the plugin-react branch September 17, 2021 15:44
aleclarson added a commit that referenced this pull request Sep 17, 2021
See #3588 for full commit history

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
aleclarson added a commit that referenced this pull request Sep 17, 2021
See #3588 for full commit history

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
aleclarson added a commit that referenced this pull request Sep 17, 2021
See #3588 for full commit history

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
aleclarson added a commit to aleclarson/vite that referenced this pull request Sep 19, 2021
See vitejs#3588 for full commit history

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
aleclarson added a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
See vitejs#3588 for full commit history

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Providing additional babel plugins for plugin-react-refresh
9 participants