Skip to content

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

Merged
aleclarson merged 76 commits into
vitejs:plugin-reactfrom
aleclarson:plugin-react
Sep 17, 2021
Merged

refactor!: migrate plugin-react-refresh to plugin-react#3588
aleclarson merged 76 commits into
vitejs:plugin-reactfrom
aleclarson:plugin-react

Conversation

@aleclarson
Copy link
Copy Markdown
Contributor

@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.

Comment thread packages/plugin-react/README.md Outdated
Comment thread packages/plugin-react/src/fast-refresh.js Outdated
@Shinigami92
Copy link
Copy Markdown
Member

I added now the new label plugin: react

Comment thread packages/plugin-react/src/fast-refresh.js Outdated
Comment thread packages/plugin-react/src/index.js Outdated
Comment thread packages/plugin-react/src/index.js Outdated
Comment thread packages/plugin-react/src/index.d.ts Outdated
Comment thread packages/plugin-react/src/index.d.ts Outdated
Comment thread packages/plugin-react/src/index.d.ts Outdated
Comment thread packages/plugin-react/package.json Outdated
@antfu antfu changed the title Add plugin-react refactor!: migrate plugin-react-refresh to plugin-react May 30, 2021
@kjeske
Copy link
Copy Markdown

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
Copy Markdown
Contributor 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
Copy Markdown
Member

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

Copy link
Copy Markdown
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

Comment thread packages/plugin-react/src/fast-refresh.ts
Comment thread packages/plugin-react/src/fast-refresh.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
Comment thread packages/plugin-react/src/jsx-runtime/babel-restore-jsx.ts Outdated
@aleclarson
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown

kjeske commented Jun 24, 2021

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

@aleclarson
Copy link
Copy Markdown
Contributor 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