-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Non-hoisted styled-jsx dependency breaks styles #9325
Comments
Adding a warning when someone tries to install |
@Timer any pointer of where and how this could be done? I'm happy to contribute. |
We don't really have any prior art, so it's open for exploration. Maybe similar to how we check if minification was disabled. |
I would probably hook into It does get complicated if you want to give a user a warning that references the correct package. For example, if An easier way might be to just check if the user's |
Is there a way to import Most of my CSS is defined in separate files that get imported into the main component files, which kinda forces me to install my own version of As described in this issue thread, this opens up the developer to package versioning issues between |
so what can i do to fix this question |
When using pnpm / yarnPnP to install next.js, styled-jsx as dependency is not hoisted in the top level node_modules, it will fail when nodejs is trying to resolve `styled-jsx/style` from project directory. Re-export `styled-jsx/style` in next.js and let swc/babel plugin compile the import path it to `next/dist/shared/lib/styled-jsx` Resolves #10149 Closes #21320 Closes #9325 Co-authored-by: Tim Neutkens <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
When
styled-jsx
with a version other than the one bundled with Next.js is manually added as a dependency to a Next.js project, style loading is delayed leading to an unstyled initial rendering flash.To Reproduce
Reproduction in: https://github.com/ctavan/next.js-reproduce-styled-jsx-bug/commits/master
Adding
styled-jsx
as a dependency manually produces the buggy behavior: ctavan/next.js-reproduce-styled-jsx-bug@489616fExpected behavior
Adding
styled-jsx
as a dependency manually should either not produce the bug or lead to a build-time error/warning in Next.js (or it should be at least documented that you should not add another version than the bundled one ofstyled-jsx
to a Next.js project).Screenshots
Here's how the
<head>
looks like, when there is NO additionalstyled-jsx
dependency. Note that the<style>
tags are included beforechunk/0.js
is loaded in a blocking fashion:Here's how the
<head>
looks like, when there is an additionalstyled-jsx
dependency (different version than the one bundled with Next.js). Note that the<style>
tags are included afterchunk/0.js
is loaded in a blocking fashion leading to html content flashing unstyled untilchunk/0.js
has been loaded:System information
The text was updated successfully, but these errors were encountered: