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
Conversation
@@ -8,7 +8,7 @@ | |||
*/ | |||
|
|||
import { | |||
registrationNameModules, | |||
registrationNames, |
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.
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( |
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.
This calls into a function that will statically enumerate each of them.
} | ||
} | ||
|
||
export function extractEvents( |
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.
This is the new static thing.
@@ -50,16 +36,3 @@ export type DispatchQueueItem = {| | |||
|}; | |||
|
|||
export type DispatchQueue = Array<DispatchQueueItem>; | |||
|
|||
export type ModernPluginModule<NativeEvent> = { |
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.
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'; |
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.
This isn't covered by Flow yet but this is preparing for your other PR.
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:
|
Details of bundled changes.Comparing: 67eb6ff...52669a8 react-dom
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (stable) |
Details of bundled changes.Comparing: 67eb6ff...52669a8 react-dom
Size changes (experimental) |
@@ -114,6 +114,74 @@ import { | |||
} from './EventListener'; | |||
import {removeTrappedEventListener} from './DeprecatedDOMEventResponderSystem'; | |||
import {topLevelEventsToDispatchConfig} from './DOMEventProperties'; | |||
import * as ModernBeforeInputEventPlugin from './plugins/ModernBeforeInputEventPlugin'; |
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.
Love this :D
eventSystemFlags: EventSystemFlags, | ||
targetContainer: null | EventTarget, | ||
) { | ||
ModernSimpleEventPlugin.extractEvents( |
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.
Do these inline fully still? Nice if they do!
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.
Yeah, these inline fully.
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.
Looks good to me! I've wanted to see this for so long, and it's finally happening :D
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.