Skip to content

external: true ignored in ssr env when returned from resolveId #20850

@marvinhagemeister

Description

@marvinhagemeister

Describe the bug

When a plugin marks a specifier as external by returning external: true in resolveId vite will fail to load the module in the ssr environment.

Reproduction

https://github.com/marvinhagemeister/deno-vite-ssr-external-bug

Steps to reproduce

  1. Clone https://github.com/marvinhagemeister/deno-vite-ssr-external-bug
  2. Install Deno https://docs.deno.com/runtime/getting_started/installation/
  3. Run deno install
  4. Run deno task dev -> visit browser

System Info

System:
    OS: macOS 15.6.1
    CPU: (8) arm64 Apple M1
    Memory: 99.59 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.8.0 - ~/.nvm/versions/node/v24.8.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.6.0 - ~/.nvm/versions/node/v24.8.0/bin/npm
    pnpm: 10.12.4 - ~/Library/pnpm/pnpm
    bun: 1.2.20 - ~/.bun/bin/bun
    Deno: 2.5.2 - ~/.deno/bin/deno
    Watchman: 2025.03.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 138.1.80.125
    Chrome: 140.0.7339.210
    Chrome Canary: 137.0.7123.0
    Safari: 18.6

Used Package Manager

npm

Logs

Click to expand!
$ deno task dev         
Task dev vite --force
2:52:17 AM [vite] (client) Forced re-optimization of dependencies

  VITE v7.1.7  ready in 688 ms

  ➜  Local:   http://127.0.0.1:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
2:52:18 AM [vite] (ssr) Error when evaluating SSR module ssr:entry: Failed to load url npm:preact (resolved id: npm:preact) in /Users/marvinhagemeister/dev/test/deno-vite/ssr.tsx. Does the file exist?
      at loadAndTransform (file:///Users/marvinhagemeister/dev/test/deno-vite/node_modules/.deno/[email protected]_1/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:26109:33)
error: Uncaught (in promise) Error: Failed to load url npm:preact (resolved id: npm:preact) in /Users/marvinhagemeister/dev/test/deno-vite/ssr.tsx. Does the file exist?

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