Files
react-native/packages/react-native-codegen
Ramanpreet Nara 3a75b376cc Create NativeModuleSchema and ComponentSchema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

## Description
The Codegen deals with "Modules". Hence:
```
type SchemaType = {
  modules: {
    [moduleName]: ...
  }
};
```

Each "Module" has a name, and represents a file. The `moduleName` is the base name of the file. This file can contain a component specification or a NativeModule specification. Hence:

```
type SchemaType = {
  modules: {
    [moduleName]: ComponentSchema | NativeModuleSchema
  }
};
```

The `ComponentSchema` can contain specifications for many different components. Hence:

```
type ComponentSchema = {
  type: 'Component'
  components: {
    [componentName]: ComponentShape
  }
}
```

The `NativeModuleSchema` contains
1. Type aliases (no surprises/nothing new).
2. One Flow interface that extends `TurboModule`.
3. Potentially many different NativeModule requires (for now) via `TurboModuleRegistry.get(Enforcing)?<specName>('moduleName')`.

Hence, the shape looks like:
```
type NativeModuleSchema = {
  type: 'NativeModule',
  aliases: NativeModuleAliasMap, // nothing new
  spec: NativeModuleSpec,
  moduleNames: $ReadOnlyArray<string>
}

type NativeModuleSpec = {
  properties: $ReadOnlyArray<...>,
}
```

## Major Notes
1. We now parse the NativeModule requires (TurboModuleRegistry.get(Enforcing)?<Spec> calls) and record them in the schema.
2. A Codegen "Module" can contain either a Component schema, or a NativeModule schema, but **not** both.

## Snapshot Updates
The changes to the schema are visible in the snapshots updated in D24236505.

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: fkgozali

Differential Revision: D24236510

fbshipit-source-id: bd344d67136418725d840e7332fd2f6957326bb4
2020-10-15 22:53:55 -07:00
..
2020-09-29 14:39:40 -07:00
2020-10-15 06:16:22 -07:00

react-native-codegen

Version

Installation

yarn add --dev react-native-codegen

Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like