-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Added react-dom/test-utils bundle #9414
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run build, you will see that there’s a single
react-test-utils.development.js
left in the/build/
folder while everything else is neatly put into folders. This is probably becausename
corresponds to npm name, but there is no top-level/packages/react-test-utils/
so it doesn’t understand where to takepackage.json
from, and skips it. (I admit this behavior is confusing.)The rule of thumb is that nothing should end up in top-level
/build/
folder, and that/build/packages/
should be all publish-able “as is” after build. I don’t think this is currently publish-able as is because test utils don’t actually make their way into thereact-dom
package.You probably want to put
'react-dom/test-utils'
in this field instead. This will ensure it gets copied into/build/packages/react-dom/
instead. You can see we are using the same trick forreact-dom/server
.However, I’m not sure how it will end up on npm. Don’t we need to add a
test-utils.js
file to/packages/react-dom/
which points to the entry point, similarly to how we haveserver.js
in/packages/react-dom/
? And we’d probably want to add more entries to"files"
in/packages/react-dom/package.json
so that the new files actually end up in the package. Otherwise this PR does not really do anything to make it appear in thereact-dom
package.I am slightly concerned about www. I would like to avoid deviating too much between how
ReactTestUtils
works in open source and in www. Currently,ReactTestUtils
is a shim (/scripts/rollup/shims/facebook-www/
) that re-exports a hidden value fromReactDOM
. If we’re separating them in open source, can we also separate them in www?The way I see it, we could do it by removing
ReactTestUtils
from the secret exports ofReactDOMFBEntry.js
andReactDOMFiberFBEntry.js
, removing theReactTestUtils.js
shim from/scripts/rollup/shims/facebook-www/
, and instead adding aFB_DEV
target to this bundle. We would need to make sure it importsrequire('react-dom')
as an external so that it doesn’t duplicateReactDOM
inside.I have a similar concern about duplication in the open source build too (which this PR implements). If you build it and look inside the bundle, it completely duplicates
ReactDOM
inside. However this means that components usingfindDOMNode
will import them fromreact-dom
that is different from the onereact-dom/test-utils
is using. If you look at 15.5,react-dom/test-utils
intentionally shared the implementation withreact-dom
itself because otherwise it can’t function correctly. So I think the need to declarereact-dom
as an external affects not only FB bundle, but open source bundle as well.Does this make sense?