nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.97k stars 394 forks source link

Hot reload not working with latest versions of @nestjs/cli #1258

Closed CodingMeSwiftly closed 3 years ago

CodingMeSwiftly commented 3 years ago

Bug Report

When following the instructions in the docs on how to add hot reload functionality to a project with cli (first paragraph), we end up with an infinite loop when running the dev script.

Current behavior

npm run dev script from docs will result in a successful build, but webpack hmr will log "[HMR] Nothing hot updated." indefinitely to the console. Screenshot 2021-07-29 at 13 42 30

Expected behavior

HMR should work with the latest versions of @nestjs/cli.

Possible Solution

I've narrowed the issue down to the installed version of @nestjs/cli. Explicitly installing 8.0.2 will work as intended.

The webpack sample works out of the box, because it has 8.0.2 of cli installed (note: not ^8.0.2).

Since npm i @nestjs/cli will install ^8.1.0 by default, new projects following the docs will most likely all run into this issue.

Environment


"@nestjs/common": "^8.0.4",
"@nestjs/core": "^8.0.4",
"@nestjs/mongoose": "^8.0.0",
"@nestjs/platform-fastify": "^8.0.5",
"@nestjs/cli": "8.1.0",
"@nestjs/schematics": "^8.0.2",


For Tooling issues:
- Node version: v16.2.0
- Platform:  macOS 11.4
krnlde commented 3 years ago

We got the same issue, and we can confirm it works with 8.0.2

Same Node Version, different OS (Windows 10 and some Linux)

NikolaPeevski commented 3 years ago

@kamilmysliwiec @CodingMeSwiftly More on this here https://github.com/webpack/webpack/issues/13876 .Downgrading webpack to 5.45 should make hmr usable in nest for the time being.

kamilmysliwiec commented 3 years ago

Downgraded to 5.45 for the time being https://github.com/nestjs/nest-cli/commit/73250b66103fa50935291e35e8a765e767fdcf36 (make sure to update @nestjs/cli to the latest version)

krnlde commented 3 years ago

It's fixed in webpack 5.48.0 https://github.com/webpack/webpack/releases/tag/v5.48.0

kamilmysliwiec commented 3 years ago

@krnlde thanks for the heads-up. We'll upgrade to the latest version very shortly, in the next patch release