-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[NEXT-684] Fast-refresh for CSS files is not working in Firefox #43396
Comments
Been trying to get started with a Next@13 + Sanity@v3 setup today. Things seemed to be working fine until I tried to change the Tailwind styling... Can confirm that HMR for Tailwind with Next > export default function Home() {
return (
<>
<div className="text-3xl font-bold underline bg-indigo-500">
Hello world!
</div>
<div className="text-3xl font-bold underline bg-indigo-700">
Hello world!
</div>
<div className="text-3xl font-bold underline bg-indigo-700">
Hello world!
</div>
</>
)
} If I change the classes and save the file, the browser does update immediately, but I change to a previously unused class, then the styling just doesn't apply at all. For example, changing the color of the last Guessing a link between Tailwind/PostCSS and Next is broken or something? 🤷♂️ |
Same issue here. You can use the solution for Turbo Pack (concurrently) in the mean time. npm install --save-dev concurrently { |
For now I have just downgraded to |
Can confirm I am experiencing the same issues with 13.0.5 and tailwind as reported by @Svish. Going back to 13.0.4 is fine. |
Just did some preliminary investigation, the defect looks to have been introduced in 13.0.5-canary.4 The canary versions prior to that do not have the issue, a few updates to the hot reloader types in that release |
For me it's not working even in previous versions :( |
Same, for me it has never worked on v13. Tailwind works but JIT classes are not added until you refresh the page. |
same problem with 13.0.6 |
It become extremelly fast when move the |
Same fixed by downgrading to 13.0.4. For anyone wondering like me how to downgrade a npm package, you just install the package again with |
Tailwind and HRM is working on |
Just tested different next.js versions with tailwind because of the hot reload error and for me it works with |
Downgrading to 13.0.4-canary.5 worked for me. MACOS Big Sur 11.4 Intel. |
Okay, just did some testing and can confirm this. I don't know how you tested, I just added a |
Digging into the changes, I think this is the culprit: Because I see the 'cache buster' suffix is no longer added to the stylesheet, making the browser unaware that its contents changed. If I refresh the stylesheet manually in a second tab, I do see the new class added to it. |
As discussed [here](https://vercel.slack.com/archives/C035J346QQL/p1668425692084449), we don't need the timestamp for CSS resources in the app dir for now as we are not preloading them. Manually tested with Safari and added corresponding e2e tests. Closes #42862. ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
We land a fix in 13.0.8-canary.0. Could you upgrade to to see if the hmr is fixed for you? |
@huozhi HMR is indeed working in 13.0.8-canary.0 when using Tailwind. |
@huozhi Working for me but I am also experiencing UI flashes similar to what @mmiszy mentioned. |
It seems to be working, though I hacked around some stuff to minimise the impact of this bug so need to validate imported stuff again. Will update if I it rears up during that refactoring but assume closed |
Tried to upgrade to version Saw the Next.js 13.1 Explained! video, where he showed off tailwind with |
antd same problem |
I was also facing this issue with tailwindcss. I'm using Next 13.2.4 and Safari 16.4. After some research, I managed to workaround this issue by adding following in headers:
process.env.NODE_ENV === 'development'
? () => [
{
source: '/_next/static/css/_app-client_src_app_globals_css.css',
headers: [{ key: 'Vary', value: '*' }],
},
]
: undefined,
This is working perfectly for me. You can read more about |
This is awesome @malviyaritesh. I confirm that with your solution, it is working for me with the latest Next.js v13.2.4 and tailwindcss 3.3.1 on both Chrome and Edge browsers. |
Works perfectly thank you!
…On Thu, 6 Apr 2023 at 15:10, NC InMe ***@***.***> wrote:
This is awesome @malviyaritesh <https://github.com/malviyaritesh>. I
confirm that with your solution, it is working for me with the latest
Next.js v13.2.4 and tailwindcss 3.3.1 on both Chrome and Edge browsers.
—
Reply to this email directly, view it on GitHub
<#43396 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK4OLDLO7EHVLZZFCQ5L5QDW72XE5ANCNFSM6AAAAAASLSQTZQ>
.
You are receiving this because you commented.Message ID: <vercel/next.
***@***.***>
|
Hey, you don't have to comment saying an issue still exists in "version x" because the issue is still open it is not fixed. Thanks! |
@timneutkens I think it's valid, so the issue doesn't get tagged as stale and ends up thrown in stale oblivion (forgotten). |
@malviyaritesh your fix stopped working between the latest releases |
Adding the vary header has no effect on this issue, it needs special handling in React which is something we're looking into. |
I also noticed that importing the global.css file from a server component (as also done in the starter template) didn't enable fast-refresh with --turbo. Once I moved the import into a client component, fast-refresh is working, without the header setting. Using Edge @13.2.4 |
I'm not sure if the workaround really works. On my end it does not help. I see people say it works, but can they verify the following: check the css file generated by TW and see if the utility you test against fast-refresh isn't in the file already. TW in development does not truncate the utilities, so when you used them once for testing of fast-refresh and then changed back, the utility still remains in the css file and when you test it later again, it appears to work, but in fact it doesn't. You need to either remove the TW output file on each test or use always a new utility class that you've never used before. TLDR; FF never receives an even that would require fetching the file again. So it will not consult the cache. Because the link's href does not change, it needs some other way to cause the browser reload the file. The method used seem not to work in FF. |
…#48578) Closes NEXT-684, closes #43396. This PR implements a temporary workaround to address the issue that some browsers are always caching CSS resources during the lifetime of a session. We re-introduce the versioning query to the resource to avoid that, and then use Mutation Observer to do GC manually on the client. Once Float handles that by itself, we can probably remove this. Note that correctly handling GC here is **required** for correctness, not an optimization. That's why it took us a while to address this (even this PR is still a temporary workaround). Imagine that if you have: ```css h1 { color: red; } ``` and then you changed it to: ```css h1 { font-size: 300px; } ``` During HMR, if we don't remove the old resources but only insert the new one, both will be applied and you will still see the `<h1>` in red, which is wrong. Here's a recording of this PR working correctly in Firefox: https://user-images.githubusercontent.com/3676859/233132831-b88e4d8d-aec9-48c4-9aa7-7c7a149b377d.mp4
I updated Next.js to 13.3.1 (which includes #48578) and fast-refresh doesn't work. When I change a Tailwind class, the browser notices the changes but the styles are not applied. I have to refresh the page manually. Did I miss anything? Is anyone experiencing the same? Tried on:
|
Whoever still copes with the issue, here's the fix: The issue is still present, but you can circumvent the issue by integrating tailwind differently. I'm not sure if this method was available before, but at least since next 13.3.1 you can integrate it via postcss as a plugin - so check your next version if it does not work. Then instead of importing the TW output css file, you import the TW input css file. The webpack loader chain this way recompiles the input file and reloads the link properly. Not need to run tailwind parallel anymore as its part of the webpack pipeline. It has been added to the docs: https://beta.nextjs.org/docs/styling/tailwind-css |
@akomm followed what you said it works, but I notice that the issue is still present if you use |
@eduardochiaro I did not test it with scss, but did you integrate scss as postcss plugin? Can you also verify that the postcss plugin is used and not just scss->css->style loaders that would normally by used when you globally import scss in next? |
@akomm I don't think is really needed, since nextjs should support it. https://nextjs.org/docs/app/building-your-application/styling/sass |
@akomm @eduardochiaro @valentincostam is it possible for you to create a small repository to reproduce this problem? |
@shuding I created this https://github.com/eduardochiaro/test-sass
Using |
…tions (#49462) In Hot Reloader we use `mod.resource.replace(/\\/g, '/').includes(key)` to see if the module is the entry. However that `includes` check isn't solid. Say the entry key is `app/path/page`, these will all be matched: ``` app/path/page.js app/path/page.css app/unrelated/app/path/page/another/page.js ``` This PR fixes that and added a test case. I'm unsure if this fixes the newly reported cases in #43396. fix NEXT-1110
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. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
So I just started a new next.js app using the
v13.0.5
with the experimentalapp
folder. I noticed that CSS changes are not correctly updated in the browser. The browser is notified of the change, but the styles are not applied - if I manually refresh the browser I can see the correct styles.I also tried the canary version and the error still exists. Moving to
v13.0.4
seems to work fine.And I also tried with Tailwind following the beta documentation and also it doesn't work.
Expected Behavior
Updating styles should fast refresh and update the page with the new styles.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://stackblitz.com/edit/vercel-next-js-viybne?file=app/global.css
To Reproduce
Open the
global.css
file, change the colors and save the file.You can see it working with the 13.0.4:
https://stackblitz.com/edit/vercel-next-js-6sncvk?file=app/global.css
NEXT-684
The text was updated successfully, but these errors were encountered: