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

Remove TestUtils dependency on event registry #19235

Merged
merged 1 commit into from Jul 1, 2020
Merged

Conversation

@gaearon
Copy link
Member

gaearon commented Jul 1, 2020

This removes the last TestUtils link to the event system internals.

The dispatch config map was used to populate the Simulate helpers. I just took a snapshot of the list we have today, and inlined it in TestUtils. We also used the config to tell whether an event is two-phased or not. However there are only four events that don't have a capture phase so I have explicitly listed them instead.

In the future we should be able to remove more of these intermediate objects in the event system itself.

@@ -40,15 +35,7 @@ function publishEventForPlugin(
eventTypes: EventTypes,
eventName: string,
): boolean {
invariant(

This comment has been minimized.

Copy link
@gaearon

gaearon Jul 1, 2020

Author Member

While this invariant is useful to us in theory we have a similar one that would catch the same issue below anyway. We should also probably make that one a DEV-only warning.

const dispatchConfig = eventNameDispatchConfigs[eventType];
// Reconstruct more or less what the original event system produced.
// We could remove this indirection here but we also don't plan to invest in Simulate anyway.
const dispatchConfig = {};

This comment has been minimized.

Copy link
@gaearon

gaearon Jul 1, 2020

Author Member

While a real dispatch config would have more fields, they're not used by TestUtils.

@trueadm
trueadm approved these changes Jul 1, 2020
@@ -549,6 +548,13 @@ function accumulateTwoPhaseDispatchesSingle(event) {

const Simulate = {};

const directDispatchEventTypes = new Set([

This comment has been minimized.

Copy link
@gaearon

gaearon Jul 1, 2020

Author Member

Not sure this actually makes sense since those should have a special enter-leave traversal? But this is what the code is already doing.

@codesandbox
Copy link

codesandbox bot commented Jul 1, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8dfb080:

Sandbox Source
thirsty-heisenberg-ve0dv Configuration
@sizebot
Copy link

sizebot commented Jul 1, 2020

Details of bundled changes.

Comparing: 9e7f5c0...8dfb080

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.0% -0.0% 878.86 KB 878.49 KB 201.23 KB 201.17 KB NODE_DEV
ReactDOMForked-prod.js -0.1% -0.1% 403.17 KB 402.91 KB 74.68 KB 74.64 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% 0.0% 136.85 KB 136.85 KB 36.34 KB 36.34 KB NODE_DEV
react-dom.production.min.js -0.1% -0.0% 119.78 KB 119.71 KB 38.43 KB 38.42 KB NODE_PROD
ReactDOMForked-profiling.js -0.1% -0.0% 413.77 KB 413.5 KB 76.44 KB 76.4 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 142.93 KB 142.93 KB 36.54 KB 36.54 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.22 KB 20.22 KB 7.58 KB 7.59 KB NODE_PROD
react-dom-test-utils.production.min.js 🔺+11.2% 🔺+12.4% 9.53 KB 10.6 KB 3.66 KB 4.11 KB UMD_PROD
ReactDOMTesting-dev.js -0.0% -0.0% 966.28 KB 965.88 KB 216.39 KB 216.32 KB FB_WWW_DEV
react-dom-test-utils.development.js +2.9% +3.7% 50.46 KB 51.94 KB 14.55 KB 15.09 KB NODE_DEV
ReactDOMTesting-prod.js -0.1% -0.1% 403.85 KB 403.59 KB 75.95 KB 75.91 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 🔺+11.3% 🔺+12.3% 9.39 KB 10.45 KB 3.58 KB 4.02 KB NODE_PROD
ReactTestUtils-dev.js +3.8% +4.4% 44.18 KB 45.86 KB 12.35 KB 12.89 KB FB_WWW_DEV
react-dom.development.js -0.0% -0.0% 923.39 KB 923 KB 203.65 KB 203.59 KB UMD_DEV
react-dom.production.min.js -0.1% -0.1% 119.66 KB 119.59 KB 39.17 KB 39.14 KB UMD_PROD
react-dom.profiling.min.js -0.1% -0.1% 123.56 KB 123.49 KB 40.35 KB 40.31 KB UMD_PROFILING
ReactDOMForked-dev.js -0.0% -0.0% 996.16 KB 995.75 KB 222.05 KB 221.99 KB FB_WWW_DEV
react-dom.profiling.min.js -0.1% 0.0% 123.84 KB 123.78 KB 39.6 KB 39.6 KB NODE_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 19.88 KB 19.88 KB 7.44 KB 7.44 KB UMD_PROD
ReactDOM-dev.js -0.0% -0.0% 1003.27 KB 1002.86 KB 223.34 KB 223.28 KB FB_WWW_DEV
ReactDOM-prod.js -0.1% -0.1% 403.37 KB 403.1 KB 74.69 KB 74.66 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% 0.0% 135.58 KB 135.58 KB 36.09 KB 36.09 KB NODE_DEV
ReactDOM-profiling.js -0.1% -0.0% 413.96 KB 413.7 KB 76.46 KB 76.42 KB FB_WWW_PROFILING
ReactDOMServer-dev.js 0.0% -0.0% 146.61 KB 146.61 KB 37.24 KB 37.24 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 47.44 KB 47.44 KB 11.11 KB 11.11 KB FB_WWW_PROD
react-dom-test-utils.development.js +2.7% +3.6% 54.86 KB 56.35 KB 15.02 KB 15.56 KB UMD_DEV

ReactDOM: size: 🔺+11.2%, gzip: 🔺+12.4%

Size changes (stable)

Generated by 🚫 dangerJS against 8dfb080

@sizebot
Copy link

sizebot commented Jul 1, 2020

Details of bundled changes.

Comparing: 9e7f5c0...8dfb080

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.0% -0.0% 909.29 KB 908.91 KB 206.76 KB 206.69 KB NODE_DEV
ReactDOMForked-prod.js -0.1% -0.1% 392.02 KB 391.76 KB 73.09 KB 73.05 KB FB_WWW_PROD
react-dom.production.min.js -0.1% -0.1% 124.25 KB 124.18 KB 39.75 KB 39.71 KB NODE_PROD
ReactDOMForked-profiling.js -0.1% -0.1% 402.56 KB 402.29 KB 74.85 KB 74.81 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 144.52 KB 144.52 KB 36.74 KB 36.74 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+11.2% 🔺+12.4% 9.54 KB 10.61 KB 3.67 KB 4.12 KB UMD_PROD
ReactDOMTesting-dev.js -0.0% -0.0% 938.26 KB 937.85 KB 210.58 KB 210.51 KB FB_WWW_DEV
react-dom-test-utils.development.js +2.9% +3.7% 50.47 KB 51.96 KB 14.56 KB 15.1 KB NODE_DEV
ReactDOMTesting-prod.js -0.1% -0.1% 390.37 KB 390.1 KB 73.87 KB 73.83 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 🔺+11.3% 🔺+12.3% 9.4 KB 10.46 KB 3.59 KB 4.03 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 5.36 KB 5.36 KB 1.8 KB 1.8 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.4% 1.17 KB 1.17 KB 667 B 664 B NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.2 KB 1.2 KB 706 B 704 B UMD_PROD
ReactTestUtils-dev.js +3.8% +4.4% 44.18 KB 45.86 KB 12.35 KB 12.89 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.87 KB 4.87 KB 1.7 KB 1.7 KB NODE_DEV
react-dom.development.js -0.0% -0.0% 955.17 KB 954.78 KB 209.28 KB 209.22 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.01 KB 1.01 KB 617 B 615 B NODE_PROD
react-dom.production.min.js -0.1% -0.0% 124.06 KB 123.99 KB 40.5 KB 40.49 KB UMD_PROD
react-dom.profiling.min.js -0.1% -0.1% 128 KB 127.94 KB 41.69 KB 41.65 KB UMD_PROFILING
ReactDOMForked-dev.js -0.0% -0.0% 970.62 KB 970.21 KB 216.94 KB 216.88 KB FB_WWW_DEV
react-dom.profiling.min.js -0.1% -0.1% 128.37 KB 128.3 KB 40.91 KB 40.88 KB NODE_PROFILING
ReactDOM-dev.js -0.0% -0.0% 977.72 KB 977.31 KB 218.25 KB 218.19 KB FB_WWW_DEV
ReactDOM-prod.js -0.1% -0.1% 392.22 KB 391.95 KB 73.11 KB 73.07 KB FB_WWW_PROD
ReactDOM-profiling.js -0.1% -0.1% 402.75 KB 402.48 KB 74.86 KB 74.83 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 20.26 KB 20.26 KB 7.51 KB 7.51 KB NODE_PROD
ReactDOMServer-prod.js 0.0% -0.0% 46.58 KB 46.58 KB 10.9 KB 10.9 KB FB_WWW_PROD
react-dom-test-utils.development.js +2.7% +3.6% 54.87 KB 56.37 KB 15.03 KB 15.57 KB UMD_DEV

ReactDOM: size: 🔺+11.2%, gzip: 🔺+12.4%

Size changes (experimental)

Generated by 🚫 dangerJS against 8dfb080

@gaearon
Copy link
Member Author

gaearon commented Jul 1, 2020

Ignore the size alert, it's talking about TestUtils.

@gaearon gaearon merged commit b683c07 into facebook:master Jul 1, 2020
32 checks passed
32 checks passed
Facebook CLA Check Contributor License Agreement is valid!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_build Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_lint_build Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_build Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_build_prod Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_dom_fixtures Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_persistent Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_prod Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_prod_www Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_prod_www_variant Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_www Your tests passed on CircleCI!
Details
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_www_variant Your tests passed on CircleCI!
Details
ci/circleci: process_artifacts Your tests passed on CircleCI!
Details
ci/circleci: process_artifacts_experimental Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: sizebot_experimental Your tests passed on CircleCI!
Details
ci/circleci: sizebot_stable Your tests passed on CircleCI!
Details
ci/circleci: yarn_build Your tests passed on CircleCI!
Details
ci/circleci: yarn_flow Your tests passed on CircleCI!
Details
ci/circleci: yarn_lint Your tests passed on CircleCI!
Details
ci/circleci: yarn_lint_build Your tests passed on CircleCI!
Details
ci/circleci: yarn_test Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build_devtools Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build_prod Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_prod Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_prod_www Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_prod_www_variant Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_www Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_www_variant Your tests passed on CircleCI!
Details
ci/codesandbox Building packages succeeded.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.