Skip to content

Please clarify wether HMR should work in the new version #72

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

Closed
swernerx opened this issue Jun 5, 2018 · 29 comments · Fixed by #73
Closed

Please clarify wether HMR should work in the new version #72

swernerx opened this issue Jun 5, 2018 · 29 comments · Fixed by #73
Assignees

Comments

@swernerx
Copy link
Contributor

swernerx commented Jun 5, 2018

I just want to figure out wether HMR should work with the newest version. I am using the newest version of both this plugin and webpack. It seems that CSS changes are correctly triggering HMR, but in the end nothing happens. This is the client-side log output:

「hot」 App updated. Recompiling src/components/card/Card.module.css
log.js:48 「hot」 webpack: Compiling (<unnamed compiler>)
log.js:48 「hot」 App Updated, Reloading Modules
log.js:48 「hot」 Checking for updates to the bundle.
log.js:48 「hot」 No Modules Updated.
log.js:48 「hot」 App is up to date.

Re-loading the app manually works fine though.

This is my loader config for CSS files:

{
  test: /\.module\.(css|sss|pcss)$/,
  use: [
    extractCssLoader,
    "cache-loader",
    "thread-loader",
    {
      loader: "css-loader",
      options: {
        import: false,
        minimize: false,
        sourceMap: true
      }
    },
    {
      loader: "postcss-loader",
      options:{
        sourceMap: true
      }
    }
  ]
}

Any hints? Previously with mini-css-extract-plugin I used the style-loader during development. Is this also the way to go with this plugin?

@ScriptedAlchemy
Copy link
Collaborator

Yes the app does does reload,can you send me your full webpack config? Also are you using webpack 4?

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

I mean the idea with HMR is that it should not reload, right?

My Webpack config is somewhat generated.

My issue is that with the old approach of using "style-loader" in development HMR works as expected while when using this plugin it just doesn't seem to correctly trigger the required changes.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

Seems like Webpack itself is doing fine:

98% after emittingCompleted client bundle in 2.914s!
ℹ 「hot」: webpack: Compiling Done
ℹ 「wdm」: Version: webpack 4.11.0
Time: 13914ms
Built at: 05.06.2018 16:37:12
Entrypoint main = main-c29587bba029864b102d.css index.js main.ef57d98abc586b5abd48.hot-update.js
ℹ 「wdm」: Compiled successfully.

There seems to be a CSS file being generated. Looks like an issue with the client side.

@ScriptedAlchemy
Copy link
Collaborator

ScriptedAlchemy commented Jun 5, 2018 via email

@ScriptedAlchemy
Copy link
Collaborator

ScriptedAlchemy commented Jun 5, 2018 via email

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

Yep, it's Webpack v4.11.0 right now. Everything using latest versions.

@ScriptedAlchemy
Copy link
Collaborator

ScriptedAlchemy commented Jun 5, 2018 via email

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

I do hash them I figure.

@ScriptedAlchemy
Copy link
Collaborator

I’m on my phone at the moment. But class check the build and see if there’s any console warnings that were thrown

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

Hashing was clearly an issue, conceptually, but does not fix the issue when disabled.

New output:

ℹ 「hot」: webpack: Bundle Invalidated
ℹ 「wdm」: Compiling...
Building client bundle...
ℹ 「hot」: webpack: Compiling...
 98% after emittingCompleted client bundle in 2.881s!
ℹ 「hot」: webpack: Compiling Done
ℹ 「wdm」: Version: webpack 4.11.0
Time: 13881ms
Built at: 05.06.2018 16:44:22
Entrypoint main = main.css index.js main.0a655b4a95cd904b6410.hot-update.js
ℹ 「wdm」: Compiled successfully.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

Content of the transferred files:

{"h":"59574152234a740a3f28","c":{"main":true}}
webpackHotUpdate("main",[])

This seems to be a little too light.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

BTW I am using the new dev-server "webpack-serve". So no SSR in place right now.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

There are no warnings. It's really just not working. Webpack output itself looks fine.

@ScriptedAlchemy
Copy link
Collaborator

Okay, I think know the issue. Do you have a repo that I can fix it on? I think for your immediate relief, im going to add hot:true to the plugin part

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

Sorry, it's in a private repo of a customer of mine. Can't really share that.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 5, 2018

I can hack into the code of your plugin though to try it out... if you give me an idea of where to look.

@ScriptedAlchemy
Copy link
Collaborator

No I fully understand! Give me a second and ill release a @next on npm which should resolve your issue

@manjula-dube
Copy link

hmr : true should solve this issue

@ScriptedAlchemy
Copy link
Collaborator

@manjula91 on the plugin or setting it in the webpack options?

@ScriptedAlchemy
Copy link
Collaborator

Okay guys Im testing a fix for this @manjula91 @swernerx

Try npm I extract-css-chunks-webpack-plugin@3.0.4-beta.1

How I currently expect things.

If you can send a snippet of were you define HOT, it will be very helpful!
Alternatively please tag me in anything you plan to release open source so I can automate it as well

  devServer: {
    contentBase: __dirname,
    hot: true,
  },

OR

    entry: {
        dev: './dev/javascript',
        index: [
            'webpack/hot/only-dev-server',
            `webpack-hot-middleware/client?path=${config.host}:${config.port}/__webpack_hmr`,
            './src/client/index.js'
        ]
    },

@ScriptedAlchemy
Copy link
Collaborator

Or npm I extract-css-chunks-webpack-plugin@next

ScriptedAlchemy added a commit that referenced this issue Jun 5, 2018
Automatic detection seems to miss a few scenarios, as a last resort. You can now add hot:true

fix #72
@ScriptedAlchemy ScriptedAlchemy self-assigned this Jun 5, 2018
@ScriptedAlchemy
Copy link
Collaborator

@swernerx

Let me know fi this helps, im at work otherwise id dedicate full time to fix it. if you still have issues.

What I had was a conditional checking the the process.env.NODE_ENV === development

secondly I have a function that determines is you use HMR

However id either are false. it won't add. For the time being you can just add hot:true to the plugin
Ill leave that there but will also look at your specific plugin at check if I can automate the test as well

Might appreciate the patience

@swernerx
Copy link
Contributor Author

swernerx commented Jun 6, 2018

Thanks. The new flag is fixing my issue.

@greyivy
Copy link

greyivy commented Jun 14, 2018

Still not working for me with hot: true, sadly. A hot update is triggered but it's empty:

webpackHotUpdate("main",[])

Using ^3.0.4-beta.1.

@ScriptedAlchemy
Copy link
Collaborator

ScriptedAlchemy commented Jun 15, 2018 via email

@greyivy
Copy link

greyivy commented Jun 18, 2018

No luck on @latest unfortunately.

@ScriptedAlchemy
Copy link
Collaborator

@hauckwill if you can, throw me a repo and ill check it

@greyivy
Copy link

greyivy commented Jun 18, 2018

Unfortunately the full repo is not mine to share, but here's my webpack config:
https://gist.github.com/hauckwill/e3fe0fe3c508bbb0e8a32c17707262c1

Using "extract-css-chunks-webpack-plugin": "^3.0.5"

Really appreciate the help and the work you've put into this.

@ScriptedAlchemy
Copy link
Collaborator

@hauckwill Ping me on https://gitter.im/Reactlandia

It will be easier & faster for me to assist over a private IM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants