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

Hot reload is not working with CSS modules, starting in 3.1.0 #7561

Closed
igorstajic opened this issue Aug 18, 2019 · 30 comments
Closed

Hot reload is not working with CSS modules, starting in 3.1.0 #7561

igorstajic opened this issue Aug 18, 2019 · 30 comments

Comments

@igorstajic
Copy link

igorstajic commented Aug 18, 2019

Describe the bug

Hot reload is not working with CSS modules, after upgrading react-scripts to 3.1.0 or 3.1.1
It works fine with react-scripts 3.0.1

Which terms did you search for in User Guide?

CSS modules hot reload

Environment

System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 10.16.2 - ~/.nvm/versions/node/v10.16.2/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.10.3 - ~/.nvm/versions/node/v10.16.2/bin/npm
Browsers:
Chrome: 76.0.3809.100
Firefox: 67.0.4
Safari: 12.1.2
npmPackages:
react: ^16.9.0 => 16.9.0
react-dom: ^16.9.0 => 16.9.0
react-scripts: 3.1.1 => 3.1.1
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. Create a new app with "npx create-react-app"
  2. Add Test.module.css file and import in in App.js
  3. Try editing the css module file, it will reload the whole app.

Expected behavior

Editing the css module should be hot reloaded.

Actual behavior

The whole app is reloaded when the css file is edited.

Reproducible demo

https://github.com/igorstajic/cra-css-module-issue

@igorstajic igorstajic changed the title Hot reload is not working with CSS modules Hot reload is not working with CSS modules, starting in 3.1.0 Aug 18, 2019
@thiphariel
Copy link

Can confirm here.
And sometimes, it even doesn't reload anything (noticed this since 3.1.0)

@wunnle
Copy link

wunnle commented Aug 31, 2019

I can confirm this too.

Just created a new project with cra to test this, I can confirm hot reloading works with imported css files, but not with (s)css modules.

Edit: Also just downgraded to 3.0.1 and hot reloading works perfectly on that version.

@chaitan94
Copy link

Not working in 3.1.2 either. Did anyone get a chance to look into this?

@stale
Copy link

stale bot commented Oct 25, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Oct 25, 2019
@Torvin
Copy link

Torvin commented Oct 25, 2019

It is still reproducible in the latest version. Is anybody working on this?

@stale stale bot removed the stale label Oct 25, 2019
@jayantbh
Copy link
Contributor

jayantbh commented Nov 22, 2019

I'm on react-scripts 3.3.0-next.62, and SCSS Modules changes trigger a full reload instead of hot-reloading like before.
I jumped from 2.1.5.

@adambowles
Copy link
Contributor

Still not fixed in 3.3.0

@spud93
Copy link

spud93 commented Dec 7, 2019

I'm having issues with hot reloading SCSS files in version 3.3.0.

@wunnle
Copy link

wunnle commented Dec 8, 2019 via email

@sudo-tee
Copy link

Same here but with less instead os scss.

Anybody have workaround ?

@dev-bjoern
Copy link

dev-bjoern commented Dec 20, 2019

Wondering, did this ever work with styled components?

@wunnle
Copy link

wunnle commented Dec 20, 2019

Same here but with less instead os scss.

Anybody have workaround ?

You can downgrade until the issue is fixed. 3.0.1 doesn't have this problem

@deluksic
Copy link

Also having this issue with 3.3.0

@chybisov
Copy link
Contributor

chybisov commented Jan 6, 2020

Same here with 3.3.0, is there any estimation for fix?

@Kiyozz
Copy link

Kiyozz commented Jan 8, 2020

3.3.0 same issue: I can't downgrade due to my Eslint config (> 6.1.0)

@lukecaan
Copy link

lukecaan commented Jan 9, 2020

Bump

@adambowles
Copy link
Contributor

Same here with 3.3.0, is there any estimation for fix?

🤷‍♂️

@Grawl
Copy link

Grawl commented Jan 21, 2020

The only workaround I found is to downgrade react-scripts to 3.0.1

-"react-scripts": "3.3.0"
+"react-scripts": "3.0.1"

@jayantbh
Copy link
Contributor

^ the only reason I'm on 3.3.0 is because of the TS upgrades (introduced in 3.3.0-next.62).
So, if anyone else is on this version for similar reasons, this might be something worth considering. This is also why I won't be downgrading just yet.

@Grawl
Copy link

Grawl commented Jan 21, 2020

In theory, you can add TS upgrades from 3.3.0 on 3.0.1 using react-app-rewired and customize-cra

@adambowles
Copy link
Contributor

adambowles commented Jan 21, 2020

Seeing as the issue started in 3.1.0, then it must be part of this diff: v3.0.1...v3.1.0

I've had a quick look through and can't see anything that might be causing it, maybe it's in one of the updated dependencies?

@Grawl
Copy link

Grawl commented Jan 22, 2020

Just checked it out with react-scripts@3.3.0 and figured out downgrading back following dependencies not solve this issue

"react-dev-utils": "^9.0.1",
"style-loader": "0.23.1",
"pnp-webpack-plugin": "1.2.1",

@lukecaan
Copy link

I really don't have any understanding at all about how this stuff works under the hood, so forgive me if I'm saying anything irrelevant/stupid, but I noticed that a new project I created a few days ago is hot reloading fine, while my older one doesn't.

Just to see if I could fix the old one, I've put them both on the exact same versions of:
react: "^16.8.6",
"react-scripts": "3.2.0",
"node-sass": "4.13.1",

cleared yarn and npm caches, deleted node_modules in both, deleted lock files in both, and then reinstalled ... but still the newer project is hot reloading perfectly, and the older one not ... what else could possibly be causing the issue??

@Grawl
Copy link

Grawl commented Jan 24, 2020

it's something in 3.1.0 update dude

@skymakerolof
Copy link

In my case, hot reloading works fine using react-scripts 3.1.2 or 3.2.0, but stop working if I upgrade to 3.3.0. I'm trying to upgrade to 3.3.0 in order to get support for typescript optional chaining. Using node-sass in this project.

@Migggz
Copy link

Migggz commented Jan 25, 2020

The same issue with react-scripts 3.3.0, I downgraded to 3.2.0 and it works fine

@chybisov
Copy link
Contributor

chybisov commented Jan 26, 2020

@adambowles @jayantbh @Grawl I just checked what dependency exactly cause issue between 3.0.1 and 3.1.0 and this is definitely due to upgrading style-loader to version 1.0.0. This version introduce some BREAKING CHANGES and these two seems exactly what we are looking for

  • the hmr option was removed, webpack automatically inject HMR code when it is required (when the HotModuleReplacementPlugin plugin was used)
  • the sourceMap option was removed. The loader automatically inject source maps if the previous loader emit them

Also I've tested downgrading style-loader to 0.23.1 in react-scripts 3.3.0 and that's works pretty fine. BUT, due to unreleased fix for webpackHotDevClient (#8075 #8079 #8084) it's still not work under https connection. After applying above fix everything works.

Finally I think we need to apply some changes to custom webpackHotDevClient to work with new version of style-loader due to those breaking changes.

Also please check this style-loader issue.

@Torvin
Copy link

Torvin commented Feb 21, 2020

Looks like this has been fixed in #8378? Appears to be working now in v3.4.0

@chybisov
Copy link
Contributor

@Torvin yep :)

hatton added a commit to BloomBooks/BloomLibrary2 that referenced this issue Feb 27, 2020
@stale
Copy link

stale bot commented Mar 22, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Mar 22, 2020
@lock lock bot locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests