Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicated chunks in rsc (tailwind styles) #323

Closed
Aslemammad opened this issue Dec 27, 2023 · 31 comments
Closed

duplicated chunks in rsc (tailwind styles) #323

Aslemammad opened this issue Dec 27, 2023 · 31 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@Aslemammad
Copy link
Contributor

large chunks in rsc which can be a short filename instead

image

@Aslemammad
Copy link
Contributor Author

working on this.

@dai-shi
Copy link
Owner

dai-shi commented Dec 27, 2023

it's dev only issue, right?

@Aslemammad
Copy link
Contributor Author

Nope, it happens in pnpm build also!

@dai-shi
Copy link
Owner

dai-shi commented Dec 27, 2023

Oh, I see.
I saw it's been sent repeatedly in DEV, but does it send the large chunk repeatedly in PRD too?

@Aslemammad
Copy link
Contributor Author

the chunk are already embedded in the html PRD, so they're not sent as far as I know (correct me). But in PRD, it's even worse, because many more chunks are being loaded this way.

image

@dai-shi
Copy link
Owner

dai-shi commented Dec 27, 2023

Oh, that's bad. That's my oversight.
Yes, this is urgent.

Right, those chunks are embedded with SSR and sent over wire with RSC.

@Aslemammad
Copy link
Contributor Author

Aslemammad commented Dec 27, 2023

@dai-shi I'm just re-reading the whole source code, do you have any hint that might help? Any filename or function name.

(if it's something you're handling, and not rsc itself)

@Aslemammad
Copy link
Contributor Author

I guess it's the router/server file.

@dai-shi
Copy link
Owner

dai-shi commented Dec 27, 2023

The large chunks are probably generated with the combination of vite and react. It has nothing to do with router, I guess. (Yeah, it might be good to reproduce the behavior without waku/router and without SSR.)
What I think is related is handler-dev.ts and rsc-renderer.ts.

@Aslemammad
Copy link
Contributor Author

  • without SSR, there's no issue.

I just started doubting if there's any problem with the chunks since they are RSC and they render on the server and then the serialized result gets injected which has so many tailwind classes, I think this is fair, let me know if I'm wrong.

@Aslemammad
Copy link
Contributor Author

The same happens in a nextjs example

image

@dai-shi
Copy link
Owner

dai-shi commented Dec 27, 2023

it's dev only issue, right?

So, back to my original understanding, it was working fine in PRD, but at some point, in DEV, we see duplicated chunks, sending same tailwind styles multiple times in the RSC payload (or embedded in html in SSR).

Do you not observe it anymore?

@Aslemammad
Copy link
Contributor Author

it was working fine in PRD

I see the tailwind chunks in PRD! But yes, it's not duplicated. In dev, only in the first run, they're duplicated; when you reload, it gets fixed. I thought this was an expected behaviour where things get cached, but I guess is wrong.

I think we should change the issue's title, because the chunks and their size are not the issue, rather the duplication is.

@dai-shi
Copy link
Owner

dai-shi commented Dec 28, 2023

Yeah, I think ideally, they shouldn't be duplicated for the first load in DEV.

@dai-shi dai-shi changed the title large chunks in rsc duplicated chunks in rsc (for the first load in DEV) Dec 28, 2023
@Aslemammad
Copy link
Contributor Author

I'll get back to this later! If anyone wants to take it meanwhile, don't hesitate!

@dai-shi dai-shi added the help wanted Extra attention is needed label Dec 28, 2023
@dai-shi
Copy link
Owner

dai-shi commented Jan 3, 2024

Hmmm, I'm not confident if it's dev only issue. Further investigation is appreciated.

@dai-shi dai-shi changed the title duplicated chunks in rsc (for the first load in DEV) duplicated chunks in rsc (tailwind styles) Jan 3, 2024
@dai-shi
Copy link
Owner

dai-shi commented Jan 4, 2024

Another issue is if we disable JS, there's no styles (reported by @himself65 )

It can be a different issue, but I think the root cause is the same.

@dai-shi dai-shi mentioned this issue Jan 4, 2024
87 tasks
@Aslemammad
Copy link
Contributor Author

Another issue is if we disable JS, there's no styles (reported by @himself65 )

dev mode or production mode? As far as I guess, this should not happen in production, but expected in dev since we support HMR that way.

@dai-shi
Copy link
Owner

dai-shi commented Jan 4, 2024

I think it's both dev and prd.

@dai-shi
Copy link
Owner

dai-shi commented Jan 4, 2024

Maybe, I'm wrong. It's dev only. Can @himself65 confirm?

@himself65
Copy link
Contributor

yeah, dev only.

@himself65
Copy link
Contributor

yeah, dev only.

There is dev css flickering because it loaded later than the JSX.

@dai-shi
Copy link
Owner

dai-shi commented Jan 5, 2024

So, it's the same as the first item in #344. I'm not sure now if it's the same root cause.

@dai-shi
Copy link
Owner

dai-shi commented Jan 8, 2024

@Aslemammad

I see the tailwind chunks in PRD! But yes, it's not duplicated.

This looks somewhat duplicated. It might not be tailwind chunks, but bright ones?

image

@Aslemammad
Copy link
Contributor Author

Aslemammad commented Jan 8, 2024 via email

@dai-shi
Copy link
Owner

dai-shi commented Jan 8, 2024

How about PRD?

@Aslemammad
Copy link
Contributor Author

Aslemammad commented Jan 8, 2024 via email

@dai-shi
Copy link
Owner

dai-shi commented Jan 8, 2024

That's what we discussed but it feels duplicated now I see it. I'm not sure if it's reasonable.

@Aslemammad
Copy link
Contributor Author

Yes, maybe! but as I saw last time, the result was not as scattered as the dev result was.

@ojj1123
Copy link
Contributor

ojj1123 commented Jan 21, 2024

The same happens in a nextjs example

Next.js team is aware of the LARGE chunks so they try to optimize RSC payload.
But yet this optimized chunks are not released (maybe they have some issue)

Reference

vercel/next.js#52028
vercel/next.js#52039
vercel/next.js#52040

@dai-shi
Copy link
Owner

dai-shi commented Mar 13, 2024

Do we still have any issues?
Otherwise, let's close it for now.

@dai-shi dai-shi closed this as completed Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants