Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

feat: use official react #34

Merged
merged 1 commit into from
Dec 3, 2020
Merged

Conversation

csr632
Copy link
Member

@csr632 csr632 commented Nov 27, 2020

Since vitejs/vite#837 is merged and released. We can use commonjs package like react and react-dom, and no longer need @pika/react and @pika/react-dom.

Why I prefer react to @pika/react:

  • @pika/react doesn't sync all versions from official react. For example, 'experimental' versions.
  • @pika/react falls behind official react. It doesn't have 17.x by now !!

BREAKING CHANGE: It requires vite>=1.0.0-rc.13. And user should install official react. I have already updated package.json in this PR.

fix: vitejs/vite-plugin-react#20
fix: vitejs/vite-plugin-react#33
fix: vitejs/vite-plugin-react#31
fix: vitejs/vite-plugin-react#29

BREAKING CHANGE: It require vite>=1.0.0-rc.13. And user should install official react.
Copy link
Member

@aleclarson aleclarson left a comment

Choose a reason for hiding this comment

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

I wonder if we should check whether the package.json of the root directory depends on react or @pika/react and use that.

src/resolver.ts Show resolved Hide resolved
@aleclarson
Copy link
Member

I'm getting an error with this setup. Can you investigate?

https://github.com/aleclarson/vite-sandbox/tree/react-34#readme

@csr632
Copy link
Member Author

csr632 commented Nov 28, 2020

I'm getting an error with this setup. Can you investigate?

https://github.com/aleclarson/vite-sandbox/tree/react-34#readme

You should add this to your vite.config.ts: jsx: "react". I have send a PR to your setup: aleclarson/vite-sandbox#2 .

I have opened a proposal to vite: let plugins define config "optimizeDeps" and "jsx". So that users don't need to manually define these option.

@aleclarson
Copy link
Member

I was trying to use React 17's new jsx-runtime, but Esbuild doesn't support it. We'll have to wait until Esbuild's plugin system is ready, apparently.

The jsx option should definitely be set by this plugin automatically. 👍

I tried with and without optimizeDeps.include: ['react', 'react-dom'] and didn't see any difference, so that part might not be needed?

@csr632
Copy link
Member Author

csr632 commented Nov 28, 2020

I tried with and without optimizeDeps.include: ['react', 'react-dom'] and didn't see any difference, so that part might not be needed?

package.json>dependencies are optimized by default: https://github.com/vitejs/vite/blob/51aead44ffb22c7d0c29a489f67b7eb7b9bba4f1/src%2Fnode%2Foptimizer%2Findex.ts#L293 .
If you put 'react' and 'react-dom' into devDependencies, you will see the difference.

@aleclarson
Copy link
Member

Why would you put those in devDependencies?

I'm gonna let @yyx990803 merge this one, so he knows to release a major version. I suggest you split the package.json changes into a v4.0.0 commit, and Evan can then use "Rebase and merge".

@csr632
Copy link
Member Author

csr632 commented Nov 30, 2020

Why would you put those in devDependencies?

So that we can use vite to develop npm library(.e.g a component library). react should be devDependency of library package.
See vitejs/vite#725

@csr632
Copy link
Member Author

csr632 commented Dec 3, 2020

@yyx990803 Could you merge and publish it when you are available? Thank you!

@yyx990803 yyx990803 merged commit ffc40cb into vitejs:master Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants