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: add react-dom in optimizeOps to handle CJS script. #375

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

Tiger3018
Copy link
Contributor

Description

The inclusion of react introduced in vite#9056 but not for react-dom. Since react-dom is a standalone package even in React 18, we should include it without problems to have consistent behavior.

Additional context

By merging this commit, CJS format js files like react-dom/client.js and react-dom/index.js will be enforced optimized, just like react's index.js.

Optimization of these files will help not-well designed (import non-default exported modules react and react-dom directly) frameworks correctly import package without developer's notice, when using the development mode of vite, e.g. resolve radix-ui/primitives#3114. More discussion of original inclusion can be seen at vite#9052/comment


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 PR Title 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.

@ArnaudBarre
Copy link
Member

@patak-dev do we have any downside except a few wasted esbuild cycles?
I don't think we have people using this plugin without React dom installed given that the Fast refresh integration relies directly on window

@patak-dev
Copy link
Member

Yes, I think it is a good idea to include it 👍🏼

@ArnaudBarre ArnaudBarre merged commit e8a923f into vitejs:main Oct 16, 2024
7 checks passed
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.

Different imports for ReactDom
3 participants