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

Make event plugin injection statically resolvable #19234

Merged
merged 7 commits into from Jul 1, 2020

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Jul 1, 2020

There are only two parts of an event "plugin". Extracting function and a list of event types.

This turns plugins into ESM that use named exports for these.
Then it changes the "plugin registry" to resolve each of these two things statically.

This makes inlining possible. Doesn't seem like it influences the size but I think this is a step towards reducing the indirection in code. The next bastion are the configs themselves.

@gaearon gaearon requested a review from trueadm July 1, 2020 20:17
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 1, 2020
@@ -8,7 +8,7 @@
*/

import {
registrationNameModules,
registrationNames,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This used to be an object hash of name -> plugin. But the plugin object wasn't actually used. I changed it to a hash of name -> true. This lets us get rid of object "plugin" representations.

targetContainer,
);
}
extractEvents(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This calls into a function that will statically enumerate each of them.

}
}

export function extractEvents(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the new static thing.

@@ -50,16 +36,3 @@ export type DispatchQueueItem = {|
|};

export type DispatchQueue = Array<DispatchQueueItem>;

export type ModernPluginModule<NativeEvent> = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This concept sort of goes away.

@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import type {EventTypes} from '../PluginModuleType';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This isn't covered by Flow yet but this is preparing for your other PR.

@gaearon gaearon changed the title Make plugin injection statically resolvable Make event plugin injection statically resolvable Jul 1, 2020
@codesandbox-ci
Copy link

codesandbox-ci 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 52669a8:

Sandbox Source
youthful-sea-lkmyf Configuration

@sizebot
Copy link

sizebot commented Jul 1, 2020

Details of bundled changes.

Comparing: 67eb6ff...52669a8

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.2% -0.3% 880.62 KB 878.86 KB 201.9 KB 201.23 KB NODE_DEV
ReactDOMForked-prod.js -0.3% -0.8% 404.21 KB 403.17 KB 75.32 KB 74.68 KB FB_WWW_PROD
react-dom-server.node.development.js -0.0% -0.0% 136.86 KB 136.85 KB 36.35 KB 36.35 KB NODE_DEV
react-dom.production.min.js -0.3% -0.3% 120.14 KB 119.78 KB 38.55 KB 38.44 KB NODE_PROD
ReactDOMForked-profiling.js -0.3% -0.8% 414.81 KB 413.77 KB 77.08 KB 76.44 KB FB_WWW_PROFILING
react-dom-server.browser.development.js -0.0% -0.0% 142.95 KB 142.93 KB 36.55 KB 36.54 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.22 KB 20.22 KB 7.59 KB 7.59 KB NODE_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 9.53 KB 9.53 KB 3.66 KB 3.66 KB UMD_PROD
ReactDOMTesting-dev.js -0.2% -0.5% 968.11 KB 966.28 KB 217.58 KB 216.39 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% 0.0% 50.46 KB 50.46 KB 14.55 KB 14.55 KB NODE_DEV
ReactDOMTesting-prod.js -0.3% -0.8% 405.09 KB 403.85 KB 76.56 KB 75.95 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 0.0% 🔺+0.1% 9.39 KB 9.39 KB 3.58 KB 3.59 KB NODE_PROD
react-dom.development.js -0.2% -0.3% 925.25 KB 923.39 KB 204.34 KB 203.65 KB UMD_DEV
react-dom.production.min.js -0.3% -0.2% 120 KB 119.66 KB 39.26 KB 39.17 KB UMD_PROD
react-dom.profiling.min.js -0.3% -0.3% 123.92 KB 123.56 KB 40.48 KB 40.36 KB UMD_PROFILING
ReactDOMForked-dev.js -0.2% -0.5% 997.96 KB 996.16 KB 223.28 KB 222.05 KB FB_WWW_DEV
react-dom.profiling.min.js -0.3% -0.5% 124.22 KB 123.84 KB 39.79 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.45 KB UMD_PROD
ReactDOM-dev.js -0.2% -0.5% 1005.06 KB 1003.27 KB 224.57 KB 223.34 KB FB_WWW_DEV
ReactDOM-prod.js -0.3% -0.8% 404.41 KB 403.37 KB 75.33 KB 74.69 KB FB_WWW_PROD
react-dom-server.browser.development.js -0.0% -0.0% 135.59 KB 135.58 KB 36.1 KB 36.09 KB NODE_DEV
ReactDOM-profiling.js -0.3% -0.8% 415 KB 413.96 KB 77.1 KB 76.46 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 19.8 KB 19.8 KB 7.43 KB 7.43 KB NODE_PROD
ReactDOMServer-dev.js -0.0% -0.0% 146.63 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 0.0% 0.0% 54.86 KB 54.86 KB 15.02 KB 15.02 KB UMD_DEV

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 52669a8

@sizebot
Copy link

sizebot commented Jul 1, 2020

Details of bundled changes.

Comparing: 67eb6ff...52669a8

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.2% -0.3% 911.04 KB 909.29 KB 207.43 KB 206.76 KB NODE_DEV
ReactDOMForked-prod.js -0.3% -0.4% 393.02 KB 392.02 KB 73.37 KB 73.09 KB FB_WWW_PROD
react-dom-server.node.development.js -0.0% -0.0% 138.38 KB 138.36 KB 36.55 KB 36.55 KB NODE_DEV
react-dom.production.min.js -0.3% -0.3% 124.61 KB 124.25 KB 39.87 KB 39.75 KB NODE_PROD
ReactDOMForked-profiling.js -0.2% -0.4% 403.55 KB 402.56 KB 75.13 KB 74.85 KB FB_WWW_PROFILING
react-dom-server.browser.development.js -0.0% -0.0% 144.53 KB 144.52 KB 36.75 KB 36.75 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.68 KB 20.68 KB 7.66 KB 7.66 KB NODE_PROD
ReactDOMTesting-dev.js -0.2% -0.4% 940.08 KB 938.26 KB 211.36 KB 210.58 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% 0.0% 50.47 KB 50.47 KB 14.56 KB 14.56 KB NODE_DEV
ReactDOMTesting-prod.js -0.3% -0.4% 391.58 KB 390.37 KB 74.14 KB 73.87 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.61 KB 5.61 KB 1.86 KB 1.87 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 🔺+0.1% 9.4 KB 9.4 KB 3.59 KB 3.59 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 5.36 KB 5.36 KB 1.8 KB 1.81 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.5% 1.17 KB 1.17 KB 666 B 669 B NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.2 KB 1.2 KB 705 B 707 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.87 KB 4.87 KB 1.7 KB 1.71 KB NODE_DEV
react-dom.development.js -0.2% -0.3% 957.03 KB 955.17 KB 209.99 KB 209.28 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.01 KB 1.01 KB 616 B 618 B NODE_PROD
react-dom.production.min.js -0.3% -0.2% 124.4 KB 124.06 KB 40.58 KB 40.5 KB UMD_PROD
react-dom.profiling.min.js -0.3% -0.3% 128.36 KB 128 KB 41.82 KB 41.7 KB UMD_PROFILING
ReactDOMForked-dev.js -0.2% -0.4% 972.41 KB 970.62 KB 217.81 KB 216.94 KB FB_WWW_DEV
react-dom.profiling.min.js -0.3% -0.4% 128.73 KB 128.37 KB 41.08 KB 40.91 KB NODE_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 20.34 KB 20.34 KB 7.52 KB 7.52 KB UMD_PROD
ReactDOM-dev.js -0.2% -0.4% 979.51 KB 977.72 KB 219.1 KB 218.25 KB FB_WWW_DEV
ReactDOM-prod.js -0.3% -0.4% 393.21 KB 392.22 KB 73.38 KB 73.11 KB FB_WWW_PROD
react-dom-server.browser.development.js -0.0% -0.0% 137.1 KB 137.09 KB 36.3 KB 36.3 KB NODE_DEV
ReactDOM-profiling.js -0.2% -0.4% 403.75 KB 402.75 KB 75.15 KB 74.87 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-dev.js -0.0% -0.0% 142.6 KB 142.58 KB 36.24 KB 36.23 KB FB_WWW_DEV
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 0.0% 0.0% 54.87 KB 54.87 KB 15.03 KB 15.03 KB UMD_DEV

Size changes (experimental)

Generated by 🚫 dangerJS against 52669a8

@@ -114,6 +114,74 @@ import {
} from './EventListener';
import {removeTrappedEventListener} from './DeprecatedDOMEventResponderSystem';
import {topLevelEventsToDispatchConfig} from './DOMEventProperties';
import * as ModernBeforeInputEventPlugin from './plugins/ModernBeforeInputEventPlugin';
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this :D

eventSystemFlags: EventSystemFlags,
targetContainer: null | EventTarget,
) {
ModernSimpleEventPlugin.extractEvents(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these inline fully still? Nice if they do!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, these inline fully.

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

Looks good to me! I've wanted to see this for so long, and it's finally happening :D

@gaearon gaearon merged commit 9e7f5c0 into facebook:master Jul 1, 2020
@gaearon gaearon deleted the static branch July 1, 2020 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants