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

[NEXTJS] css style rules duplication across page/layout/loading #1276

Open
2 tasks done
zecka opened this issue Jan 18, 2024 · 3 comments
Open
2 tasks done

[NEXTJS] css style rules duplication across page/layout/loading #1276

zecka opened this issue Jan 18, 2024 · 3 comments
Labels
nextjs Issue related to NextJS upstream issue Issue caused by a required upstream dependency

Comments

@zecka
Copy link

zecka commented Jan 18, 2024

Describe the bug

Any way to avoid style duplication across generated css for page layout or loading page ?

If i use same component in both a client component inside a page and inside the layout his style will be generated inside page.css and layout.css

image

In above example (reproduction repository):

  • inside <ClientComponent> i have <Demo /> component (client component have notation 'use client')
  • inside /app/page.tsx i have <ClientComponent /> component
  • inside /app/layout.tsx i have <Demo /> component

If i remove 'use client'; from <ClientComponent> the css style of demo will not be duplicate on page.css
image

I use vanilla extract in a component library using atomic design. So it's like having a lot of duplicated css rules...

Is there a way to force vanilla extract to bundle one css file instead of multiple css chunk ?

Note that i got exactly the same issue using css module.

Heres is other thread that seems to be related

Not sure if this thread should be inside issue or discussion...

Reproduction

https://github.com/zeckaissue/next-css-duplicated/tree/vanilla-extract

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (16) x64 Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
    Memory: 18.50 GB / 24.76 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 18.17.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm
    pnpm: 8.6.2 - /usr/local/bin/pnpm
  npmPackages:
    @vanilla-extract/css: ^1.14.0 => 1.14.0 
    @vanilla-extract/next-plugin: ^2.3.2 => 2.3.2

Used Package Manager

yarn

Logs

No response

Validations

@askoufis askoufis added nextjs Issue related to NextJS and removed pending triage labels Jan 21, 2024
@zecka
Copy link
Author

zecka commented Feb 25, 2024

v 14.1.1-canary.43 seems to fix this issue
Pull request: vercel/next.js#61198

Let's wait for version 14.1.1 of next to close this issue definitively.

@zecka
Copy link
Author

zecka commented Mar 9, 2024

Tested again on v. 14.1.2 but isse still there 😢

@maiconsanson
Copy link

I'm using 14.1.3 and it seems fixed for me (production only, dev still duplicating).

@askoufis askoufis added the upstream issue Issue caused by a required upstream dependency label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nextjs Issue related to NextJS upstream issue Issue caused by a required upstream dependency
Projects
None yet
Development

No branches or pull requests

3 participants