Files
react/packages/react-flight-dom-webpack/src/ReactFlightDOMServerBrowser.js
T
Sebastian Markbåge 8206b4b864 Wire up bundler configs (#18334)
This allows different flight server and clients to have different configs
depending on bundler to serialize and resolve modules.
2020-03-18 12:18:34 -07:00

37 lines
839 B
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {ReactModel} from 'react-server/src/ReactFlightServer';
import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
import {
createRequest,
startWork,
startFlowing,
} from 'react-server/src/ReactFlightServer';
function renderToReadableStream(
model: ReactModel,
webpackMap: BundlerConfig,
): ReadableStream {
let request;
return new ReadableStream({
start(controller) {
request = createRequest(model, controller, webpackMap);
startWork(request);
},
pull(controller) {
startFlowing(request);
},
cancel(reason) {},
});
}
export {renderToReadableStream};