@samitouri / QOS-React-2 / commits / c3e20f18fe

Add Relay specific React Native build of Flight (#20149)

This adds a new dimension similar to dom-relay. It's different from "native" which would be Flight for RN without Relay. This has some copy-pasta that's the same between the two Relay builds but the key difference will be Metro and we're not quite sure what other differences there will be yet.

Sebastian Markbåge committed Nov 2, 2020 at 21:49 UTC c3e20f18fe37993ddcbf11dccb55663b4c0d02fd
24 files changed +711 -2
.circleci/config.yml
+2
@@ -242,6 +242,7 @@ jobs:
242 - RELEASE_CHANNEL
243 - facebook-www
244 - facebook-react-native
245 + - facebook-relay
246 - node_modules
247 - react-native
248 - dist
@@ -268,6 +269,7 @@ jobs:
269 - RELEASE_CHANNEL
270 - facebook-www
271 - facebook-react-native
272 + - facebook-relay
273 - node_modules
274 - react-native
275 - dist
.eslintrc.js
+4 -1
@@ -188,7 +188,10 @@ module.exports = {
188 },
189 },
190 {
191 - files: ['packages/react-native-renderer/**/*.js'],
191 + files: [
192 + 'packages/react-native-renderer/**/*.js',
193 + 'packages/react-transport-native-relay/**/*.js'
194 + ],
195 globals: {
196 nativeFabricUIManager: true,
197 },
packages/react-client/src/forks/ReactFlightClientHostConfig.native-relay.js new
+11
@@ -0,0 +1,11 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from 'react-transport-native-relay/src/ReactFlightNativeRelayClientHostConfig';
11 +export * from '../ReactFlightClientHostConfigNoStream';
packages/react-reconciler/src/forks/ReactFiberHostConfig.native-relay.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from 'react-native-renderer/src/ReactFabricHostConfig';
packages/react-server/src/ReactNativeServerFormatConfig.js new
+23
@@ -0,0 +1,23 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import {convertStringToBuffer} from 'react-server/src/ReactServerStreamConfig';
11 +
12 +export function formatChunkAsString(type: string, props: Object): string {
13 + let str = '<' + type + '>';
14 + if (typeof props.children === 'string') {
15 + str += props.children;
16 + }
17 + str += '</' + type + '>';
18 + return str;
19 +}
20 +
21 +export function formatChunk(type: string, props: Object): Uint8Array {
22 + return convertStringToBuffer(formatChunkAsString(type, props));
23 +}
packages/react-server/src/forks/ReactFlightServerConfig.native-relay.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from 'react-transport-native-relay/src/ReactFlightNativeRelayServerHostConfig';
packages/react-server/src/forks/ReactServerFormatConfig.native-relay.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from '../ReactNativeServerFormatConfig';
packages/react-server/src/forks/ReactServerStreamConfig.native-relay.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from '../ReactServerStreamConfigNode';
packages/react-transport-native-relay/index.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from './src/ReactFlightNativeRelayClient';
packages/react-transport-native-relay/package.json new
+18
@@ -0,0 +1,18 @@
1 +{
2 + "name": "react-transport-native-relay",
3 + "version": "0.1.0",
4 + "private": true,
5 + "repository": {
6 + "type" : "git",
7 + "url" : "https://github.com/facebook/react.git",
8 + "directory": "packages/react-transport-native-relay"
9 + },
10 + "dependencies": {
11 + "object-assign": "^4.1.1",
12 + "scheduler": "^0.11.0"
13 + },
14 + "peerDependencies": {
15 + "react": "^17.0.0",
16 + "react-native-renderer": "^17.0.0"
17 + }
18 +}
packages/react-transport-native-relay/server.js new
+10
@@ -0,0 +1,10 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export * from './src/ReactFlightNativeRelayServer';
packages/react-transport-native-relay/src/ReactFlightNativeRelayClient.js new
+16
@@ -0,0 +1,16 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +export {
11 + createResponse,
12 + resolveModel,
13 + resolveModule,
14 + resolveError,
15 + close,
16 +} from 'react-client/src/ReactFlightClient';
packages/react-transport-native-relay/src/ReactFlightNativeRelayClientHostConfig.js new
+60
@@ -0,0 +1,60 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import type {JSONValue, ResponseBase} from 'react-client/src/ReactFlightClient';
11 +
12 +import type JSResourceReference from 'JSResourceReference';
13 +
14 +export type ModuleReference<T> = JSResourceReference<T>;
15 +
16 +import {
17 + parseModelString,
18 + parseModelTuple,
19 +} from 'react-client/src/ReactFlightClient';
20 +
21 +export {
22 + resolveModuleReference,
23 + preloadModule,
24 + requireModule,
25 +} from 'ReactFlightNativeRelayClientIntegration';
26 +
27 +export type {ModuleMetaData} from 'ReactFlightNativeRelayClientIntegration';
28 +
29 +export opaque type UninitializedModel = JSONValue;
30 +
31 +export type Response = ResponseBase;
32 +
33 +function parseModelRecursively(response: Response, parentObj, value) {
34 + if (typeof value === 'string') {
35 + return parseModelString(response, parentObj, value);
36 + }
37 + if (typeof value === 'object' && value !== null) {
38 + if (Array.isArray(value)) {
39 + for (let i = 0; i < value.length; i++) {
40 + (value: any)[i] = parseModelRecursively(response, value, value[i]);
41 + }
42 + return parseModelTuple(response, value);
43 + } else {
44 + for (const innerKey in value) {
45 + (value: any)[innerKey] = parseModelRecursively(
46 + response,
47 + value,
48 + value[innerKey],
49 + );
50 + }
51 + }
52 + }
53 + return value;
54 +}
55 +
56 +const dummy = {};
57 +
58 +export function parseModel<T>(response: Response, json: UninitializedModel): T {
59 + return (parseModelRecursively(response, dummy, json): any);
60 +}
packages/react-transport-native-relay/src/ReactFlightNativeRelayServer.js new
+27
@@ -0,0 +1,27 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import type {ReactModel} from 'react-server/src/ReactFlightServer';
11 +import type {
12 + BundlerConfig,
13 + Destination,
14 +} from './ReactFlightNativeRelayServerHostConfig';
15 +
16 +import {createRequest, startWork} from 'react-server/src/ReactFlightServer';
17 +
18 +function render(
19 + model: ReactModel,
20 + destination: Destination,
21 + config: BundlerConfig,
22 +): void {
23 + const request = createRequest(model, destination, config);
24 + startWork(request);
25 +}
26 +
27 +export {render};
packages/react-transport-native-relay/src/ReactFlightNativeRelayServerHostConfig.js new
+170
@@ -0,0 +1,170 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import type {Request, ReactModel} from 'react-server/src/ReactFlightServer';
11 +
12 +import JSResourceReferenceImpl from 'JSResourceReferenceImpl';
13 +
14 +export type ModuleReference<T> = JSResourceReferenceImpl<T>;
15 +
16 +import type {
17 + Destination,
18 + BundlerConfig,
19 + ModuleMetaData,
20 +} from 'ReactFlightNativeRelayServerIntegration';
21 +
22 +import {resolveModelToJSON} from 'react-server/src/ReactFlightServer';
23 +
24 +import {
25 + emitModel,
26 + emitModule,
27 + emitError,
28 + resolveModuleMetaData as resolveModuleMetaDataImpl,
29 +} from 'ReactFlightNativeRelayServerIntegration';
30 +
31 +export type {
32 + Destination,
33 + BundlerConfig,
34 + ModuleMetaData,
35 +} from 'ReactFlightNativeRelayServerIntegration';
36 +
37 +export function isModuleReference(reference: Object): boolean {
38 + return reference instanceof JSResourceReferenceImpl;
39 +}
40 +
41 +export function resolveModuleMetaData<T>(
42 + config: BundlerConfig,
43 + resource: ModuleReference<T>,
44 +): ModuleMetaData {
45 + return resolveModuleMetaDataImpl(config, resource);
46 +}
47 +
48 +type JSONValue =
49 + | string
50 + | number
51 + | boolean
52 + | null
53 + | {+[key: string]: JSONValue}
54 + | Array<JSONValue>;
55 +
56 +export type Chunk =
57 + | {
58 + type: 'json',
59 + id: number,
60 + json: JSONValue,
61 + }
62 + | {
63 + type: 'module',
64 + id: number,
65 + json: ModuleMetaData,
66 + }
67 + | {
68 + type: 'error',
69 + id: number,
70 + json: {
71 + message: string,
72 + stack: string,
73 + ...
74 + },
75 + };
76 +
77 +export function processErrorChunk(
78 + request: Request,
79 + id: number,
80 + message: string,
81 + stack: string,
82 +): Chunk {
83 + return {
84 + type: 'error',
85 + id: id,
86 + json: {
87 + message,
88 + stack,
89 + },
90 + };
91 +}
92 +
93 +function convertModelToJSON(
94 + request: Request,
95 + parent: {+[key: string]: ReactModel} | $ReadOnlyArray<ReactModel>,
96 + key: string,
97 + model: ReactModel,
98 +): JSONValue {
99 + const json = resolveModelToJSON(request, parent, key, model);
100 + if (typeof json === 'object' && json !== null) {
101 + if (Array.isArray(json)) {
102 + const jsonArray: Array<JSONValue> = [];
103 + for (let i = 0; i < json.length; i++) {
104 + jsonArray[i] = convertModelToJSON(request, json, '' + i, json[i]);
105 + }
106 + return jsonArray;
107 + } else {
108 + const jsonObj: {[key: string]: JSONValue} = {};
109 + for (const nextKey in json) {
110 + jsonObj[nextKey] = convertModelToJSON(
111 + request,
112 + json,
113 + nextKey,
114 + json[nextKey],
115 + );
116 + }
117 + return jsonObj;
118 + }
119 + }
120 + return json;
121 +}
122 +
123 +export function processModelChunk(
124 + request: Request,
125 + id: number,
126 + model: ReactModel,
127 +): Chunk {
128 + const json = convertModelToJSON(request, {}, '', model);
129 + return {
130 + type: 'json',
131 + id: id,
132 + json: json,
133 + };
134 +}
135 +
136 +export function processModuleChunk(
137 + request: Request,
138 + id: number,
139 + moduleMetaData: ModuleMetaData,
140 +): Chunk {
141 + // The moduleMetaData is already a JSON serializable value.
142 + return {
143 + type: 'module',
144 + id: id,
145 + json: moduleMetaData,
146 + };
147 +}
148 +
149 +export function scheduleWork(callback: () => void) {
150 + callback();
151 +}
152 +
153 +export function flushBuffered(destination: Destination) {}
154 +
155 +export function beginWriting(destination: Destination) {}
156 +
157 +export function writeChunk(destination: Destination, chunk: Chunk): boolean {
158 + if (chunk.type === 'json') {
159 + emitModel(destination, chunk.id, chunk.json);
160 + } else if (chunk.type === 'module') {
161 + emitModule(destination, chunk.id, chunk.json);
162 + } else {
163 + emitError(destination, chunk.id, chunk.json.message, chunk.json.stack);
164 + }
165 + return true;
166 +}
167 +
168 +export function completeWriting(destination: Destination) {}
169 +
170 +export {close} from 'ReactFlightNativeRelayServerIntegration';
packages/react-transport-native-relay/src/__mocks__/JSResourceReferenceImpl.js new
+19
@@ -0,0 +1,19 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +class JSResourceReferenceImpl {
11 + constructor(exportedValue) {
12 + this._moduleId = exportedValue;
13 + }
14 + getModuleId() {
15 + return this._moduleId;
16 + }
17 +}
18 +
19 +module.exports = JSResourceReferenceImpl;
packages/react-transport-native-relay/src/__mocks__/ReactFlightNativeRelayClientIntegration.js new
+22
@@ -0,0 +1,22 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +import JSResourceReference from 'JSResourceReference';
11 +
12 +const ReactFlightNativeRelayClientIntegration = {
13 + resolveModuleReference(moduleData) {
14 + return new JSResourceReference(moduleData);
15 + },
16 + preloadModule(moduleReference) {},
17 + requireModule(moduleReference) {
18 + return moduleReference._moduleId;
19 + },
20 +};
21 +
22 +module.exports = ReactFlightNativeRelayClientIntegration;
packages/react-transport-native-relay/src/__mocks__/ReactFlightNativeRelayServerIntegration.js new
+38
@@ -0,0 +1,38 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +const ReactFlightNativeRelayServerIntegration = {
11 + emitModel(destination, id, json) {
12 + destination.push({
13 + type: 'json',
14 + id: id,
15 + json: json,
16 + });
17 + },
18 + emitModule(destination, id, json) {
19 + destination.push({
20 + type: 'module',
21 + id: id,
22 + json: json,
23 + });
24 + },
25 + emitError(destination, id, message, stack) {
26 + destination.push({
27 + type: 'error',
28 + id: id,
29 + json: {message, stack},
30 + });
31 + },
32 + close(destination) {},
33 + resolveModuleMetaData(config, resource) {
34 + return resource._moduleId;
35 + },
36 +};
37 +
38 +module.exports = ReactFlightNativeRelayServerIntegration;
packages/react-transport-native-relay/src/__tests__/ReactFlightNativeRelay-test.internal.js new
+127
@@ -0,0 +1,127 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +let React;
11 +let ReactFabric;
12 +let createReactNativeComponentClass;
13 +let View;
14 +let Text;
15 +let JSResourceReferenceImpl;
16 +let ReactNativeFlightRelayServer;
17 +let ReactNativeFlightRelayClient;
18 +
19 +describe('ReactFlightNativeRelay', () => {
20 + beforeEach(() => {
21 + jest.resetModules();
22 +
23 + require('react-native/Libraries/ReactPrivate/InitializeNativeFabricUIManager');
24 +
25 + React = require('react');
26 + // TODO: Switch this out to react-native
27 + ReactFabric = require('react-native-renderer/fabric');
28 + createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface')
29 + .ReactNativeViewConfigRegistry.register;
30 + View = createReactNativeComponentClass('RCTView', () => ({
31 + validAttributes: {},
32 + uiViewClassName: 'RCTView',
33 + }));
34 + Text = createReactNativeComponentClass('RCTText', () => ({
35 + validAttributes: {},
36 + uiViewClassName: 'RCTText',
37 + }));
38 +
39 + ReactNativeFlightRelayServer = require('react-transport-native-relay/server');
40 + ReactNativeFlightRelayClient = require('react-transport-native-relay');
41 + JSResourceReferenceImpl = require('JSResourceReferenceImpl');
42 + });
43 +
44 + function readThrough(data) {
45 + const response = ReactNativeFlightRelayClient.createResponse();
46 + for (let i = 0; i < data.length; i++) {
47 + const chunk = data[i];
48 + if (chunk.type === 'json') {
49 + ReactNativeFlightRelayClient.resolveModel(
50 + response,
51 + chunk.id,
52 + chunk.json,
53 + );
54 + } else if (chunk.type === 'module') {
55 + ReactNativeFlightRelayClient.resolveModule(
56 + response,
57 + chunk.id,
58 + chunk.json,
59 + );
60 + } else {
61 + ReactNativeFlightRelayClient.resolveError(
62 + response,
63 + chunk.id,
64 + chunk.json.message,
65 + chunk.json.stack,
66 + );
67 + }
68 + }
69 + ReactNativeFlightRelayClient.close(response);
70 + const model = response.readRoot();
71 + return model;
72 + }
73 +
74 + it('can render a server component', () => {
75 + function Bar({text}) {
76 + return <Text>{text.toUpperCase()}</Text>;
77 + }
78 + function Foo() {
79 + return {
80 + bar: (
81 + <View>
82 + <Bar text="a" /> <Bar text="b" />
83 + </View>
84 + ),
85 + };
86 + }
87 + const transport = [];
88 + ReactNativeFlightRelayServer.render(
89 + {
90 + foo: <Foo />,
91 + },
92 + transport,
93 + );
94 +
95 + const model = readThrough(transport);
96 + expect(model).toMatchSnapshot();
97 + });
98 +
99 + it('can render a client component using a module reference and render there', () => {
100 + function UserClient(props) {
101 + return (
102 + <Text>
103 + {props.greeting}, {props.name}
104 + </Text>
105 + );
106 + }
107 + const User = new JSResourceReferenceImpl(UserClient);
108 +
109 + function Greeting({firstName, lastName}) {
110 + return <User greeting="Hello" name={firstName + ' ' + lastName} />;
111 + }
112 +
113 + const model = {
114 + greeting: <Greeting firstName="Seb" lastName="Smith" />,
115 + };
116 +
117 + const transport = [];
118 + ReactNativeFlightRelayServer.render(model, transport);
119 +
120 + const modelClient = readThrough(transport);
121 +
122 + ReactFabric.render(modelClient.greeting, 1);
123 + expect(
124 + nativeFabricUIManager.__dumpHierarchyForJestTestsOnly(),
125 + ).toMatchSnapshot();
126 + });
127 +});
packages/react-transport-native-relay/src/__tests__/__snapshots__/ReactFlightNativeRelay-test.internal.js.snap new
+25
@@ -0,0 +1,25 @@
1 +// Jest Snapshot v1, https://goo.gl/fbAQLP
2 +
3 +exports[`ReactFlightNativeRelay can render a client component using a module reference and render there 1`] = `
4 +"1
5 + RCTText null
6 + RCTRawText {\\"text\\":\\"Hello\\"}
7 + RCTRawText {\\"text\\":\\", \\"}
8 + RCTRawText {\\"text\\":\\"Seb Smith\\"}"
9 +`;
10 +
11 +exports[`ReactFlightNativeRelay can render a server component 1`] = `
12 +Object {
13 + "foo": Object {
14 + "bar": <RCTView>
15 + <RCTText>
16 + A
17 + </RCTText>
18 +
19 + <RCTText>
20 + B
21 + </RCTText>
22 + </RCTView>,
23 + },
24 +}
25 +`;
scripts/flow/react-relay-hooks.js
+50
@@ -17,12 +17,21 @@ type JSONValue =
17
18 declare class JSResourceReference<T> {
19 _moduleId: T;
20 + getModuleId(): string;
21 }
22
23 +// Haste
24 declare module 'JSResourceReference' {
25 declare export default typeof JSResourceReference;
26 }
27
28 +// Metro
29 +declare module 'JSResourceReferenceImpl' {
30 + declare export default class JSResourceReferenceImpl<
31 + T,
32 + > extends JSResourceReference<T> {}
33 +}
34 +
35 declare module 'ReactFlightDOMRelayServerIntegration' {
36 declare export opaque type Destination;
37 declare export opaque type BundlerConfig;
@@ -63,3 +72,44 @@ declare module 'ReactFlightDOMRelayClientIntegration' {
72 moduleReference: JSResourceReference<T>,
73 ): T;
74 }
75 +
76 +declare module 'ReactFlightNativeRelayServerIntegration' {
77 + declare export opaque type Destination;
78 + declare export opaque type BundlerConfig;
79 + declare export function emitModel(
80 + destination: Destination,
81 + id: number,
82 + json: JSONValue,
83 + ): void;
84 + declare export function emitModule(
85 + destination: Destination,
86 + id: number,
87 + json: ModuleMetaData,
88 + ): void;
89 + declare export function emitError(
90 + destination: Destination,
91 + id: number,
92 + message: string,
93 + stack: string,
94 + ): void;
95 + declare export function close(destination: Destination): void;
96 +
97 + declare export type ModuleMetaData = JSONValue;
98 + declare export function resolveModuleMetaData<T>(
99 + config: BundlerConfig,
100 + resourceReference: JSResourceReference<T>,
101 + ): ModuleMetaData;
102 +}
103 +
104 +declare module 'ReactFlightNativeRelayClientIntegration' {
105 + declare export opaque type ModuleMetaData;
106 + declare export function resolveModuleReference<T>(
107 + moduleData: ModuleMetaData,
108 + ): JSResourceReference<T>;
109 + declare export function preloadModule<T>(
110 + moduleReference: JSResourceReference<T>,
111 + ): void;
112 + declare export function requireModule<T>(
113 + moduleReference: JSResourceReference<T>,
114 + ): T;
115 +}
scripts/rollup/bundles.js
+27 -1
@@ -298,7 +298,7 @@ const bundles = [
298 ],
299 },
300
301 - /******* React DOM Flight Client Relay *******/
301 + /******* React Transport DOM Client Relay *******/
302 {
303 bundleTypes: [FB_WWW_DEV, FB_WWW_PROD],
304 moduleType: RENDERER,
@@ -311,6 +311,32 @@ const bundles = [
311 ],
312 },
313
314 + /******* React Transport Native Server Relay *******/
315 + {
316 + bundleTypes: [RN_FB_DEV, RN_FB_PROD],
317 + moduleType: RENDERER,
318 + entry: 'react-transport-native-relay/server',
319 + global: 'ReactFlightNativeRelayServer',
320 + externals: [
321 + 'react',
322 + 'ReactFlightNativeRelayServerIntegration',
323 + 'JSResourceReferenceImpl',
324 + ],
325 + },
326 +
327 + /******* React Transport Native Client Relay *******/
328 + {
329 + bundleTypes: [RN_FB_DEV, RN_FB_PROD],
330 + moduleType: RENDERER,
331 + entry: 'react-transport-native-relay',
332 + global: 'ReactFlightNativeRelayClient',
333 + externals: [
334 + 'react',
335 + 'ReactFlightNativeRelayClientIntegration',
336 + 'JSResourceReferenceImpl',
337 + ],
338 + },
339 +
340 /******* React ART *******/
341 {
342 bundleTypes: [
scripts/rollup/packaging.js
+2
@@ -79,6 +79,8 @@ function getBundleOutputPath(bundleType, filename, packageName) {
79 /\.js$/,
80 '.fb.js'
81 )}`;
82 + case 'react-transport-native-relay':
83 + return `build/facebook-relay/flight/${filename}`;
84 default:
85 throw new Error('Unknown RN package.');
86 }
scripts/shared/inlinedHostConfigs.js
+10
@@ -91,6 +91,16 @@ module.exports = [
91 isFlowTyped: true,
92 isServerSupported: true,
93 },
94 + {
95 + shortName: 'native-relay',
96 + entryPoints: [
97 + 'react-transport-native-relay',
98 + 'react-transport-native-relay/server',
99 + ],
100 + paths: ['react-native-renderer', 'react-transport-native-relay'],
101 + isFlowTyped: true,
102 + isServerSupported: true,
103 + },
104 {
105 shortName: 'custom',
106 entryPoints: [