Add view config babel plugin

Summary:
This diff adds a babel plugin for the generated view configs which will inline them in the file instead of needing to check the view configs in (fb only)

The way it works is:
- babel reads the code
- looks for type alias `CodegenNativeComponent` in `*NativeComponet.js` files
- run the flow parser on the file source to create a schema
- run the schema into codegen to get the view config source code
- inject the generated source code back into the NativeComponent.js file
- remove the original export
- profit

After this diff we will remove the `js1 build viewconfigs` command and the checked-in NativeViewConfig.js files

Note: since this plugin is not published to open source, for now OSS will continue using the `requireNativeComponent` function

Reviewed By: cpojer

Differential Revision: D15516062

fbshipit-source-id: a8efb077773e04fd9753a7036682eeaae9175e09
This commit is contained in:
Rick Hanlon
2019-06-07 12:31:36 -07:00
committed by Facebook Github Bot
parent 886fb501bd
commit efec97f2be
14 changed files with 298 additions and 23 deletions
+4 -1
View File
@@ -14,7 +14,10 @@ const FlowParser = require('../../parsers/flow');
function parseFiles(files: Array<string>) {
files.forEach(filename => {
console.log(filename, JSON.stringify(FlowParser.parse(filename), null, 2));
console.log(
filename,
JSON.stringify(FlowParser.parseFile(filename), null, 2),
);
});
}