Use babel-plugin-inline-view-configs to increase verification of viewmanagers#5431
Use babel-plugin-inline-view-configs to increase verification of viewmanagers#54316 commits merged intomicrosoft:masterfrom
babel-plugin-inline-view-configs to increase verification of viewmanagers#5431Conversation
| @@ -1,3 +1,4 @@ | |||
| module.exports = { | |||
| presets: ['module:metro-react-native-babel-preset'], | |||
| plugins: [require('../../vnext/src/babel-plugin-inline-view-configs')], | |||
There was a problem hiding this comment.
Consider adding this to e2etest as well
|
Hello @acoates-ms! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
@acoates-ms, the core components (View, Text, TextInput, Image, and ScrollView) are handwritten and not using codegen. The theory has been that these are complex and unique enough that handwriting them is okay. I think you've raised a really good point though, enforcing that the other platforms are consistent via build failures is important. The decision came from only thinking about Android and iOS. I've raised this with the members of the team working on Fabric. While I hope we change direction on the plan for codegen of those platforms, I wouldn't expect it to come for those components before 2021. 😕 |
babel-plugin-inline-view-configsis a plugin that core uses which among other things adds some runtime validation that the property types and event types being declared in the view configs of viewmangers match the view specs in js.This PR copies the
babel-plugin-inline-view-configsplugin into RNW since its not yet publicly published. Then it applies facebook/react-native#29230 on top of it which is required before the plugin would work outside of Facebooks haste repo. It also makes some changes to use a local copy ofreact-native-codegenthat we have, which is required untilreact-native-codegenis republished after this PR was merged: facebook/react-native#28827Finally we apply this plugin in the playground app, so RNTester will hit errors if a viewmanager declares an event or property with the wrong type/parameters.
@TheSavior , one thing to note is that the number of viewmanagers that this currently checks is pretty limited. It checks
Viewand a few of the less important viewmanagers (ex:Slider), but there doesn't appear to be a native view spec forText? It also doesnt checkScrollViewsince the view spec for that goes through a redirect inScrollViewNativeComponent.jswhich only adds the call toregisterGeneratedViewConfigwhen running inRN$Bridgelessmode. It also doesn't checkTextInput, since we forked the native component there too much, so we are not using the native spec.Microsoft Reviewers: Open in CodeFlow