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

improvements: set react and react-dom alias in webpack #3698

Closed
wants to merge 1 commit into from

Conversation

maomaoZH
Copy link

@maomaoZH maomaoZH commented Jan 5, 2018

set react and react-dom alias in webpack to avoid loading twice react during developing. This issue has been discussed, see here #675. I have tested with my app locally. The duplicated react issue is gone after set up alias.

…to avoid react loading twice when developing
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

I feel like in a way this just works around the problem instead of solving it. I would prefer it we completely failed the build with multiple react / react-doms and printed where they are in the tree so you could figure out how to deduplicate them and fix the root issue.

@maciej-ka
Copy link
Contributor

I wonder how it's possible to deduplicate. npm link perhaps?

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

It depends on the exact scenario in which you're seeing duplication (there are many possible solutions).

@maomaoZH
Copy link
Author

Okay, let me explain the case that we've been facing. Then we may understand/talk the way how we resolve it. After that, I can improve this pull request.

First, we have an application which is obviously created by create-react-app and using a dependency that we have been developing. That dependency contains our React UI components. Therefore, we need to link the dependency to our main application during the development. So this case cause multiple copies of React issue.

I think that we may resolve the issue in this way that we have in this branch. Besides that, there is such a workaround, here. But the latter one would be a real workaround than the changes we have here in my opinion.

Therefore, I'm wondering how we can resolve the issue. Could you explain that?

@gaearon
Copy link
Contributor

gaearon commented Jan 11, 2018

We are tracking the "npm link" use case in #1107. Not sure if there's any great solutions for it.

Ideally I'd like us to fix #1333. This wouldn't solve "linking" per se, but it would add a supported way to develop components alongside the app. Would that satisfy your use case?

The reason I'm not very happy with aliasing react and react-dom in particular is because the problem with links still exists: we just work around it for two particular packages. You may still bump into it with other dependencies. So I'd like to see if we can solve this more holistically.

@gaearon
Copy link
Contributor

gaearon commented Jan 21, 2018

Related: #3883

Seems like this is actually the root of the problem. Pardon the module resolution pun.

@stale
Copy link

stale bot commented Nov 2, 2018

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018
@stale
Copy link

stale bot commented Nov 7, 2018

This pull request has been automatically closed because it has not had any recent activity. The conversation will be locked in 7 days unless the pull request is reopened. Thank you for your contribution.

@stale stale bot closed this Nov 7, 2018
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants