Skip to content

Hot reloading of linked modules doesn't work on server #5463

@maerzhase

Description

@maerzhase

Bug report

When working with next and a linked module, the hot reloading doesn't work on the server but only on the client.

Describe the bug

When you have a linked module inside the node_modules folder the module is only replaced on the client but not on the server. This means that you have to restart the whole next application in order to render the updated module on the server.
When the module is a React.Component and the output change this even results in inconsistent rendering between server and client shown in a error message in the console.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Setup clean next-js app
  2. Link a module via npm link my-module
  3. Import the module anywhere e.g. pages/index
  4. Start next-js in dev mode
  5. Change your linked module e.g. add console.log or if React.Component change render method. this will trigger a reload (see terminal)
  6. Changes are only visible in the client. server still loads the previous version of the module (probably from cache)

Expected behavior

The require.cache gets cleared properly so the linked module will be re-required also on the server. so client and server stay in sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions