Skip to content

Incorrect HMR payload when using multiple environments with different root #17393

@lazarv

Description

@lazarv

Describe the bug

I am using the new Environment API with multiple environments: client, ssr, rsc
I have different root configuration for the ssr and rsc environments
On file change, HMR payload is incorrect for the environments where the root is different than the main Vite config's root

Reproduction

https://stackblitz.com/edit/vitejs-vite-krepgb?file=server.js,folder-a%2Ffile-a.js&terminal=dev

Steps to reproduce

Start Vite dev server by running pnpm dev
Change the content of ./folder-a/file-a.js which is imported by ./folder-b/file-b.js which is imported by a ModuleRunner using the RSC environment's transport.
Check that HMR payload is incorrect, triggeredBy path is /home/projects/vitejs-vite-krepgb/folder-b/file-a.js, which doesn't exist, folder is incorrect.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: 6.0.0-alpha.18 => 6.0.0-alpha.18

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions