bridge: Updating to latest nuxt-bridge version breaks Webpack HMR
Environment
- Operating System:
Darwin - Node Version:
v16.18.0 - Nuxt Version:
2.16.0-27720022.54e852f - Nitro Version:
0.6.0 - Package Manager:
npm@8.19.2 - Builder:
webpack - User Config:
bridge,head,css,plugins,components,buildModules,build,serverHandlers,devServerHandlers,typescript - Runtime Modules:
- - Build Modules:
(),@nuxtjs/stylelint-module@4.1.0,@nuxt/bridge@3.0.0-27778503.de9e5c2
Reproduction
https://github.com/linhmtran168/test-nuxt-bridge
Just a clean create-nuxt-app updated to use latest nuxt-bridge version
Describe the bug
Nuxt Bridge latest version: @nuxt/bridge@3.0.0-27778503.de9e5c2 breaks webpack HMR with the following error in browser console:
GET http://localhost:3001/__webpack_hmr/client 404 (Not Found)
Downgrading to 3.0.0-27747000.69db93e fixes the problem
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 23 (2 by maintainers)
Instead of patching
node_modulesyou can also do the conversion within thereadyhook in yournuxt.config.ts:To use Webpack HMR with latest
nuxt-bridge, you can patch@nuxt/webpack-edgepackage by using npm’spatch-packagepackage or pnpm. New versions of Nitro require node middleware to be converted toh3handler and the hook for running middleware also changed. The following patch works for me:The issue still exists on
@nuxt/bridge-edge@3.0.0-27830071.32c4527I’ve downgraded to 3.0.0-27747000.69db93e and now other bridge methods stopped working for me… I think we need a proper fix for this issue
@sreuss Thanks a lot! Finally, it works
For those who are not using typescript:
@Draccano Yes.
nuxt-bridgeusenuxifor all command line operations. For me, I fixed thenuxt-bridgeversion inpackage.jsonas follows and rannpm installagain, then Webpack HRM worked normallysame in 3.0.0-27851925.695ddd7
This also fixed HMR for me. I am using yarn and this worked for me:
Then just do what the command line prompts. Open the file, change it and then commit the patch. It should look something like this: