Skip to content

__filename and __dirname in SSR #6899

@cyco130

Description

@cyco130

Describe the bug

__filename and __dirname are undefined and cause a reference error in modules loaded with ssrLoadModule. They work correctly in the production build.

Reproduction

https://stackblitz.com/edit/vitejs-vite-seqgmn?file=index.js

System Info

System:
    OS: Linux 5.4 Linux Mint 20.3 (Una)
    CPU: (8) x64 Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
    Memory: 793.16 MB / 15.52 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.1 - /usr/local/bin/node
    Yarn: 1.22.11 - ~/.npm-global/bin/yarn
    npm: 8.3.0 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Firefox: 97.0
  npmPackages:
    vite: ^2.8.1 => 2.8.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions