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

Unnecessary styles for multi tenant style app #67704

Open
G3EORG3E opened this issue Jul 12, 2024 · 0 comments
Open

Unnecessary styles for multi tenant style app #67704

G3EORG3E opened this issue Jul 12, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`). Webpack Related to Webpack with Next.js.

Comments

@G3EORG3E
Copy link

G3EORG3E commented Jul 12, 2024

Link to the code that reproduces this issue

https://github.com/G3EORG3E/multi-tenant

To Reproduce

  1. build app
  2. start app
  3. see that resulting styles for page includes also styles of components that is not rendered in page

Current vs. Expected behavior

I am trying to implement multi tenant app. And each app instance can have different component depending on its configured theme. For example we can see I have a parent <Header/> server component that imports <MinimalisticHeader/> and <ModernHeader/> and decides which component to render depending on app theme.

Currently the page includes styles of both <MinimalisticHeader/> and <ModernHeader/> but only <ModernHeader/> is rendered in server component.

I would expect that the page would have styles only for components that are actually rendered in server component (at least when they are dynamically imported there) otherwise its not possible to build such apps with Next.js, its unacceptable to have styles for every theme loaded.

Edit: Additionally, I observed that the client components are also being added to the bundle. A mechanism to prevent this inclusion is necessary. This is unusable for bigger more complex apps.

Provide environment information

Not related to environment

Which area(s) are affected? (Select all that apply)

Lazy Loading, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

No response

@G3EORG3E G3EORG3E added the bug Issue was opened via the bug report template. label Jul 12, 2024
@github-actions github-actions bot added Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`). Webpack Related to Webpack with Next.js. labels Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`). Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant