vercel / next-react-server-components

Demo repository for Next.js + React Server Components
https://next-rsc-hn.vercel.app
MIT License
976 stars 156 forks source link

Server dependency is being included in the frontend bundle #52

Closed fredcido closed 1 year ago

fredcido commented 1 year ago

Hey all, first of all thank you for the interesting demo.

It seems that the demo is quite not fulfilling one of the main purposes of RSC, which is to keep server dependency in the server.

Example:

// ./components/Time.server.js

import moment from "moment";

const Time = () => {
  return <p>{moment().format("DD/MM/yyyy H:mm")}</p>;
};

export default Time;
// ./pages/index.js 

import { Suspense } from "react";
import Time from "../components/Time.server";

export default function Index() {
  return (
    <Suspense fallback={"Loading..."}>
      <Time />
    </Suspense>
  );
}

The moment dependency is being included into the client bundle, checked the chunks into .next/static folder and also with @next/bundle-analyzer:

image
bishopwm commented 1 year ago

I'm seeing this as well.

Maybe you have some insights Vercel team? 😄 @huozhi @shuding @leerob

leerob commented 1 year ago

Hey there! We do not recommend profiling the repository right now, as there will be bugs, and we're switching the architecture as we move towards the work defined in the Layouts RFC, which uses Server Components by default.