Skip to content

module runner full reload error when importing node_modules dependency as entry #19975

@hi-ogawa

Description

@hi-ogawa

Describe the bug

I use my own package as module runner entry server.environments.ssr.runner.import("my-package"), but this causes an error on full reload hi-ogawa/vite-plugins#742.

Here is a minimal repro:

$ node repro.js
[vite] connected.
[TEST] file:///home/projects/github-5yembwxu/node_modules/.pnpm/file+fixtures+test-dep/node_modules/test-dep/index.js
[vite] program reload
[vite] An error happened during full reload
Failed to load url test-dep.js (resolved id: test-dep.js). Does the file exist?
Error: Failed to load url test-dep.js (resolved id: test-dep.js). Does the file exist?
    at loadAndTransform (file:///home/projects/parigpvogv.github/node_modules/.pnpm/vite@6.3.4/node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35788:17)

Now that #19283 is fixed, this can be worked around by wrapping entry with a virtual module, but I suspect there's still minor resolution issue around module runner and fetchModule.

Reproduction

https://stackblitz.com/edit/github-5yembwxu?file=repro.js

Steps to reproduce

open stackblitz

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: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^6.3.4 => 6.3.4

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions