Repository: facebook/react
File: packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js (JavaScript)

Code before:
    nextSuspenseID: responseState.nextSuspenseID,
    streamingFormat: responseState.streamingFormat,
    startInlineScript: responseState.startInlineScript,
    instructions: responseState.instructions,
    externalRuntimeScript: responseState.externalRuntimeScript,
    htmlChunks: responseState.htmlChunks,
    headChunks: responseState.headChunks,
    hasBody: responseState.hasBody,
    charsetChunks: responseState.charsetChunks,
    preconnectChunks: responseState.preconnectChunks,
    preloadChunks: responseState.preloadChunks,
    hoistableChunks: responseState.hoistableChunks,
    stylesToHoist: responseState.stylesToHoist,

    // This is an extra field for the legacy renderer
    generateStaticMarkup,
  };
}

import {
  stringToChunk,
  stringToPrecomputedChunk,
} from 'react-server/src/ReactServerStreamConfig';

// this chunk is empty on purpose because we do not want to emit the DOCTYPE in legacy mode
const DOCTYPE = stringToPrecomputedChunk('');

export function createRootFormatContext(): FormatContext {
  return {
    insertionMode: ROOT_HTML_MODE,
    selectedValue: null,
    noscriptTagInScope: false,
    DOCTYPE,
  };
}

export type {
  Resources,
  BoundaryResources,
  FormatContext,
  SuspenseBoundaryID,
} from './ReactFizzConfigDOM';

export {
  getChildFormatContext,
  UNINITIALIZED_SUSPENSE_BOUNDARY_ID,
  assignSuspenseBoundaryID,
  makeId,
  pushStartInstance,
  pushEndInstance,
  pushStartCompletedSuspenseBoundary,

Review comment (suggestion):
You could just export the DOCTYPE and then import it from the config that's overridden from itself.

Since legacy is always its own build, we don't need it to be a stateful field.

Code after:
    startInlineScript: responseState.startInlineScript,
    instructions: responseState.instructions,
    externalRuntimeScript: responseState.externalRuntimeScript,
    htmlChunks: responseState.htmlChunks,
    headChunks: responseState.headChunks,
    hasBody: responseState.hasBody,
    charsetChunks: responseState.charsetChunks,
    preconnectChunks: responseState.preconnectChunks,
    preloadChunks: responseState.preloadChunks,
    hoistableChunks: responseState.hoistableChunks,
    stylesToHoist: responseState.stylesToHoist,

    // This is an extra field for the legacy renderer
    generateStaticMarkup,
  };
}

import {
  stringToChunk,
  stringToPrecomputedChunk,
} from 'react-server/src/ReactServerStreamConfig';

// this chunk is empty on purpose because we do not want to emit the DOCTYPE in legacy mode
export const doctypeChunk: PrecomputedChunk = stringToPrecomputedChunk('');

export type {
  Resources,
  BoundaryResources,
  FormatContext,
  SuspenseBoundaryID,
} from './ReactFizzConfigDOM';

export {
  getChildFormatContext,
  UNINITIALIZED_SUSPENSE_BOUNDARY_ID,
  assignSuspenseBoundaryID,
  makeId,
  pushStartInstance,
  pushEndInstance,
  pushStartCompletedSuspenseBoundary,
  pushEndCompletedSuspenseBoundary,
  writeStartSegment,
  writeEndSegment,
  writeCompletedSegmentInstruction,
  writeCompletedBoundaryInstruction,
  writeClientRenderBoundaryInstruction,
  writeStartPendingSuspenseBoundary,
  writeEndPendingSuspenseBoundary,
  writeResourcesForBoundary,
  writePlaceholder,
  writeCompletedRoot,