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

SCSS module is not loading on route change when using dynamic import #18252

Closed
SZharkov opened this issue Oct 26, 2020 · 8 comments
Closed

SCSS module is not loading on route change when using dynamic import #18252

SZharkov opened this issue Oct 26, 2020 · 8 comments

Comments

@SZharkov
Copy link
Contributor

SZharkov commented Oct 26, 2020

Bug report

After I've implemented dynamic loading of components - some of the components are not loading their scss module when changing the page. I see no issues in dev mode and that's only related to the production.

Describe the bug

My app is dynamic, pages and sections are generated dynamically (based on received data from the server).
It works this way:

  1. I open the homepage. All the components are working ok.
  2. Using navbar I navigate to another page (without page refresh) and from this point some of the components are loaded without styles.
  3. Once I refresh the page - styles are working again

System information

  • Latest version of Next.js
@jamesmosier
Copy link
Contributor

Hi @SZharkov. Can you please provide a full reproduction of this issue in a repository?

@jamesmosier jamesmosier added the please add a complete reproduction The issue lacks information for further investigation label Oct 27, 2020
@SZharkov
Copy link
Contributor Author

@jamesmosier that's problematic, because the project is private. And I am not sure whether trying to reproduce from scratch will show this issue. I just hope that somebody faces the same issue.
I guess that the problem could be related to this part of code -

let dynamicCssFiles = dedupe(
. When changing the page it just stops injecting css for some components.

@SZharkov
Copy link
Contributor Author

@jamesmosier you can find the reproduction in this repo - https://github.com/SZharkov/dynamic-import-no-styles.
Just next build and next start. Then try to navigate between pages, for example from homepage to page1 etc, and you will see that the styles are not applied for some of the components for example text is dark while it should be red. Then when you see this inconsistency - reload page, styles will be ok again, but try to navigate to another page and they will be broken again.

@SZharkov
Copy link
Contributor Author

SZharkov commented Nov 4, 2020

@jamesmosier do you have any update? :)

@jamesmosier jamesmosier removed the please add a complete reproduction The issue lacks information for further investigation label Nov 9, 2020
@zenhob
Copy link

zenhob commented Nov 10, 2020

I am seeing the same behavior, but with productions builds only, it works as expected in development mode.

@SZharkov
Copy link
Contributor Author

SZharkov commented Nov 15, 2020

Really would appreciate to hear some thoughts. This bug blocks me from optimizing projects using dynamic imports and that affects negatively on page speed and scores too much 😞

@Timer
Copy link
Member

Timer commented Nov 16, 2020

This was fixed on next@canary.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants