Skip to content

Vite hijacks import.meta.resolve resulting in broken configuration files #20326

@runspired

Description

@runspired

Describe the bug

I am using import.meta.resolve to resolve configuration files and entry points while generating my vite config. I expect this to work, except it doesn't because vite appends /node_modules/.vite-temp to every path.

Reproduction

https://stackblitz.com/edit/vitejs-vite-sbaj8ewe?file=package.json&view=editor

Steps to reproduce

create a config that uses import.meta.resolve to locate something like a babel config file or an entry point

System Info

System:
    OS: macOS 15.5
    CPU: (16) arm64 Apple M3 Max
    Memory: 52.94 GB / 128.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.0.1 - ~/.volta/tools/image/node/24.0.1/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 11.3.0 - ~/.volta/tools/image/node/24.0.1/bin/npm
    pnpm: 10.12.4 - ~/.volta/tools/image/pnpm/10.12.4/bin/pnpm
    bun: 1.2.17 - ~/.bun/bin/bun
    Watchman: 2025.05.26.00 - /opt/homebrew/bin/watchman

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions