Skip to content

Commit

Permalink
__next_rsc__.server
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 28, 2022
1 parent ae15161 commit 6f7059f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Expand Up @@ -174,19 +174,19 @@ export default async function transformSource(
*
* Server compilation output:
* (The content of the Server Component module will be kept.)
* export const __next_rsc__ = { __webpack_require__, _: () => { ... } }
* export const __next_rsc__ = { __webpack_require__, _: () => { ... }, server: true }
*
* Client compilation output:
* (The content of the Server Component module will be removed.)
* export const __next_rsc__ = { __webpack_require__, _: () => { ... } }
* export const __next_rsc__ = { __webpack_require__, _: () => { ... }, server: false }
*/

const rscExports: any = {
__next_rsc__: `{
__webpack_require__,
_: () => {\n${imports}\n}
_: () => {\n${imports}\n},
server: ${isServerComponent(resourcePath) ? 'true' : 'false'}
}`,
__next_rsc_server__: isServerComponent(resourcePath) ? 'true' : 'false',
}

if (isClientCompilation) {
Expand Down
1 change: 0 additions & 1 deletion packages/next/client/index.tsx
Expand Up @@ -648,7 +648,6 @@ function AppContainer({
}

function renderApp(App: AppComponent, appProps: AppProps) {
console.log('isRSCPage', isRSCPage)
if (process.env.__NEXT_RSC && isRSCPage) {
const { Component, err: _, router: __, ...props } = appProps
return <Component {...props} />
Expand Down
1 change: 0 additions & 1 deletion packages/next/server/dev/next-dev-server.ts
Expand Up @@ -686,7 +686,6 @@ export default class DevServer extends Server {
}
}

console.error(err)
if (!usedOriginalStack) {
if (type === 'warning') {
Log.warn(err + '')
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/load-components.ts
Expand Up @@ -58,7 +58,7 @@ export async function loadDefaultErrorComponents(distDir: string) {
reactLoadableManifest: {},
ComponentMod,
AppMod,
// TODO detect server components
// Use App for fallback
AppServerMod: AppMod,
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/next/server/render.tsx
Expand Up @@ -364,9 +364,7 @@ const useFlightResponse = createFlightHook()

// Create the wrapper component for a Flight stream.
function createServerComponentRenderer(
// OriginalComponent: React.ComponentType,
AppMod: any,
// App: any,
ComponentMod: any,
{
cachePrefix,
Expand Down Expand Up @@ -472,7 +470,7 @@ export async function renderToHTML(
const isServerComponent =
hasConcurrentFeatures &&
!!serverComponentManifest &&
!!ComponentMod.__next_rsc_server__
!!ComponentMod.__next_rsc__?.server

let Component: React.ComponentType<{}> | ((props: any) => JSX.Element) =
renderOpts.Component
Expand Down

0 comments on commit 6f7059f

Please sign in to comment.