Skip to content

resolve conditions not respected when running the dev server / ssrLoadModule #14496

@marbemac

Description

@marbemac

Describe the bug

I am setting resolve.conditions to ["workerd", "worker", "browser"], and ssr.target to webworker, so that imported packages use the browser/worker/edge versions if available.

This works fine during vite build, but it seems these config options are not respected when running the vite dev server or manually creating a server and using ssrLoadModule.

Reproduction

https://github.com/marbemac/vite-ssr-resolve-bug

Steps to reproduce

yarn followed by yarn start. Note the console logs out undefined for the renderToReadableStream import. This indicates the import resolved to the node version of react, despite the ssr target and resolve conditions.

System Info

System:
    OS: macOS 13.5.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 60.00 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.13.0/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
    pnpm: 8.8.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 117.0.5938.132
    Safari: 16.6
  npmPackages:
    vite: 4.4.9 => 4.4.9

Used Package Manager

yarn

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