Unverified Commit f5917ad3 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix server component render condition (#35663)

We are currently using `!!ComponentMod.__next_rsc__` as the hint for the renderer to tell if the component is a server component, however that export field (`__next_rsc__`) is assigned to client components (`.client.[ext]`) as well. 

This PR adds a new `__next_rsc_server__` field which is only true when the component is a server component so the renderer can handle client components correctly.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
parent 41a2eb23
...@@ -186,6 +186,7 @@ export default async function transformSource( ...@@ -186,6 +186,7 @@ export default async function transformSource(
__webpack_require__, __webpack_require__,
_: () => {\n${imports}\n} _: () => {\n${imports}\n}
}`, }`,
__next_rsc_server__: isServerComponent(resourcePath) ? 'true' : 'false',
} }
if (isClientCompilation) { if (isClientCompilation) {
......
...@@ -469,9 +469,9 @@ export async function renderToHTML( ...@@ -469,9 +469,9 @@ export async function renderToHTML(
// We don't need to opt-into the flight inlining logic if the page isn't a RSC. // We don't need to opt-into the flight inlining logic if the page isn't a RSC.
const isServerComponent = const isServerComponent =
!!serverComponentManifest &&
hasConcurrentFeatures && hasConcurrentFeatures &&
!!ComponentMod.__next_rsc__ !!serverComponentManifest &&
!!ComponentMod.__next_rsc_server__
let Component: React.ComponentType<{}> | ((props: any) => JSX.Element) = let Component: React.ComponentType<{}> | ((props: any) => JSX.Element) =
renderOpts.Component renderOpts.Component
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment