mirror of
https://github.com/facebook/react.git
synced 2026-02-25 05:03:03 +00:00
* Move files * Update paths * Rename import variables * Rename /server to /writer This is mainly because "React Server Server" is weird so we need another dimension. * Use "react-server" convention to enforce that writer is only loaded in a server
35 lines
881 B
JavaScript
35 lines
881 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 type {Writable} from 'stream';
|
|
|
|
import {
|
|
createRequest,
|
|
startWork,
|
|
startFlowing,
|
|
} from 'react-server/src/ReactFlightServer';
|
|
|
|
function createDrainHandler(destination, request) {
|
|
return () => startFlowing(request);
|
|
}
|
|
|
|
function pipeToNodeWritable(
|
|
model: ReactModel,
|
|
destination: Writable,
|
|
webpackMap: BundlerConfig,
|
|
): void {
|
|
const request = createRequest(model, destination, webpackMap);
|
|
destination.on('drain', createDrainHandler(destination, request));
|
|
startWork(request);
|
|
}
|
|
|
|
export {pipeToNodeWritable};
|