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

CSS Module resolution conflict with dynamic import in production mode #40080

Open
1 task done
6220119 opened this issue Aug 30, 2022 · 5 comments
Open
1 task done

CSS Module resolution conflict with dynamic import in production mode #40080

6220119 opened this issue Aug 30, 2022 · 5 comments
Labels
bug Issue was opened via the bug report template.

Comments

@6220119
Copy link

6220119 commented Aug 30, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

next info

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 14.20.0
      npm: 6.14.17
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 12.2.6-canary.5
      eslint-config-next: 12.2.5
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

Not relevant

How are you deploying your application? (if relevant)

next export (pages are statically generated, and deployed on a host, i.e. Github Pages)

Describe the Bug

The CSS Module resolved in production mode does not match with the development's.

Expected Behavior

At the minimum, the same output should be the same in development mode, so that we are not caught by surprise.

Link to reproduction

https://github.com/6220119/nextjs-css-module-dynamic-import-bug

To Reproduce

Steps to reproduce

The Reproduction site is live at: https://6220119.github.io/nextjs-css-module-dynamic-import-bug/

at the time of writing, this issue is reproducible with next@canary (12.2.6-canary.5)

  1. Load the Home page (/ route).
  2. Observe that the "Blue" and "Red" buttons are displayed correctly.
  3. Click Go to Contact page.
  4. Observe that the Contact page is displayed properly with the base (grey) button.
  5. Click Go to Home page.
  6. [FAIL], Expect that the "Blue" and "Red" buttons are displayed correctly.
    • Blue and Red buttons become "grey", due to CSS overriding from a newly added <style> element,
      under the marker <noscript data-n-css=""></noscript>

Note

  • The issue doesn't happen if the Contact page is the first page loaded (at step 3, do a page refresh).
  • The issue also doesn't happen in local development (because style-loader is used in dev mode instead of css-loader)

Video capture

Screen.Recording.mp4
@6220119 6220119 added the bug Issue was opened via the bug report template. label Aug 30, 2022
@MarcARoberge
Copy link

I am also having this issue. This bug is reproducible through the router but if I land directly on my page it works as intended.

@jonime
Copy link

jonime commented Dec 9, 2022

We are also having this issue. This causes some weird style errors in our project 😞

@maerzhase
Copy link
Contributor

also having this issue. pretty nasty

@Egor-Dubovik
Copy link

I have the same issue in next@13.5.6 even without dynamic imports. Seriously this problem has been going on for so long and it still hasn't been fixed?

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.
Projects
None yet
Development

No branches or pull requests

5 participants