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 cannot work #1932

Closed
lyz810 opened this issue Jan 27, 2022 · 9 comments
Closed

Hot Reload cannot work #1932

lyz810 opened this issue Jan 27, 2022 · 9 comments

Comments

@lyz810
Copy link

lyz810 commented Jan 27, 2022

Current behavior
Hot Reload cannot work

To reproduce
Upgrade react-styleguidist from 11.1.8 to 11.2.0

11.1.8 works well

Expected behavior

@juanca
Copy link
Contributor

juanca commented Jan 27, 2022

Which Webpack version are you using?

@juanca
Copy link
Contributor

juanca commented Jan 27, 2022

Just for another data point. I tested with Webpack 5 and it works. It should work with Webpack 4.

@lyz810
Copy link
Author

lyz810 commented Jan 28, 2022

Which Webpack version are you using?
version of webpack: 5.67.0
I can't find any kind of websocket request in Chrome Network Panel
image

I tried to revert part of new changes in 11.2.0(change the file in node_modules, and restart)
92518df#diff-5c873f8bf346d5bd54eaebda2215d65647f4f53a4b3e84987d520091d0d913f9L122
It didn't work, but something differerent in Chrome Network Panel
image

Then, I downgrade to 11.1.8,and restart the project, everything is ok
image

├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected] deduped
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ @webpack-cli/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
└─┬ [email protected]
└─┬ [email protected]
└── [email protected] deduped

@lyz810
Copy link
Author

lyz810 commented Jan 28, 2022

add entry,plugins,devServer.sockPath should work

{ 
entry: [require.resolve('react-dev-utils/webpackHotDevClient')],
plugins: [new _webpack.default.HotModuleReplacementPlugin()],
devServer: {
    transportMode: 'ws',
    sockPath: 'ws'
}
}

@lyz810
Copy link
Author

lyz810 commented Jan 28, 2022

[email protected]
https://github.com/facebook/create-react-app/blob/react-dev-utils%4011.0.3/packages/react-dev-utils/webpackHotDevClient.js#L66

[email protected]
https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/webpackHotDevClient.js#L66

if process.env.WDS_SOCKET_PATH is not set, default value change between two versions(old default value was /sockjs-node, an new default value is /ws)

and if we dont pass sockPath to devSever config, the webpack-dev-server will use /sockjs-node as default:
https://github.com/webpack/webpack-dev-server/blob/v3.11.3/lib/Server.js#L108

That's why the websocket request is always pending even if I add entry and pulgins back to the node_modules source code.

@lyz810
Copy link
Author

lyz810 commented Jan 28, 2022

I find the solution of this case:

Add following config into styleguide.config.js

{
  webpackConfig: {
    devServer: {
      injectClient: true,
    },
  },
},

I think it can be added in here:
https://github.com/styleguidist/react-styleguidist/blob/master/src/scripts/make-webpack-config.ts#L123

@juanca
Copy link
Contributor

juanca commented Feb 1, 2022

I see the issue. The recent Webpack 5 compatibility is based on webpack-dev-server@^4. See the migration guide for v4.

I'm not sure what is the best next step:

  • Is it possible to support both versions (^3 and ^4)?
  • Is it appropriate to specify webpack-dev-server as a dependency?

@stale
Copy link

stale bot commented May 2, 2022

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

@stale stale bot added the wontfix label May 2, 2022
@sapegin sapegin closed this as completed in a460fcc Sep 5, 2022
@github-actions
Copy link

github-actions bot commented Sep 5, 2022

🎉 This issue has been resolved in version 12.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants