nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.69k stars 2.36k forks source link

@nx/next:custom-server brakes webpack HMR #21493

Open stomvi opened 9 months ago

stomvi commented 9 months ago

Current Behavior

Regardless of the issue #21481 I reported, clean installed custom server brakes webpack HMR. ws://localhost:4200/_next/webpack-hmr request was successfully upgraded to websocket at the first load. But nothing changed or triggered at the client side while root page.tsx file was changed.

I don't know if this bug had anything to do with the rebuilding action messages showed at the console. The console showed SWC re-builded files and the debugger listened on a new websocket URL each time. This happened while components were modified and even while nothing was changed but the page is RELOADED.

While page.tsx file is modified:

[ ready ] on http://localhost:4200
Successfully compiled www/app/page.tsx with swc (4.34ms)
Debugger listening on ws://localhost:9229/21cb6ce3-def4-446d-b3cc-f80961cb5817
Debugger listening on ws://localhost:9229/21cb6ce3-def4-446d-b3cc-f80961cb5817
For help, see: https://nodejs.org/en/docs/inspector

While http://localhost:4200/ is reloaded manually:

[ ready ] on http://localhost:4200
 ○ Compiling / ...
Successfully compiled www/.next/types/app/layout.ts with swc (7.9ms)
Successfully compiled www/.next/types/app/page.ts with swc (8.77ms)
Successfully compiled www/.next/types/app/page.ts with swc (4.06ms)
Successfully compiled www/.next/types/app/layout.ts with swc (8.1ms)
 ✓ Compiled / in 1459ms (427 modules)
Debugger listening on ws://localhost:9229/487606e3-60c7-4e4e-8fa7-3957065b9f6b
Debugger listening on ws://localhost:9229/487606e3-60c7-4e4e-8fa7-3957065b9f6b
For help, see: https://nodejs.org/en/docs/inspector

Expected Behavior

HMR should work.

GitHub Repo

No response

Steps to Reproduce

1.npx create-nx-workspace test --preset=next --appName=www --nextAppDir=true --nextSrcDir=false --nxCloud=skip --style=scss --e2eTestRunner=cypress

  1. cd test
  2. npx nx g @nx/next:custom-server --project=www --compiler=swc

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : darwin-arm64
   npm    : 10.2.3

   nx                 : 17.3.1
   @nx/js             : 17.3.1
   @nx/jest           : 17.3.1
   @nx/linter         : 17.3.1
   @nx/eslint         : 17.3.1
   @nx/workspace      : 17.3.1
   @nx/cypress        : 17.3.1
   @nx/devkit         : 17.3.1
   @nx/eslint-plugin  : 17.3.1
   @nx/next           : 17.3.1
   @nx/react          : 17.3.1
   @nrwl/tao          : 17.3.1
   @nx/web            : 17.3.1
   typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

github-actions[bot] commented 6 days ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏