Skip to content

SSR resolve always happens as require even when it's an import #10352

@benmccann

Description

@benmccann

Describe the bug

Svelte has a package.json in each directory to support older versions of Node. On Node 12+ the exports map will be used. Even on newer versions of Node, Vite appears to be looking at the nested package.json rather than the exports map, which is incorrect. This only happens with the external config.

Originally reported in sveltejs/vite-plugin-svelte#360

Reproduction

git clone [email protected]:benmccann/context-issue.git
cd context-issue/svelte-kit-app
npm install
npm run dev

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 293.67 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.9.0 - ~/.nvm/versions/node/v17.9.0/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v17.9.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v17.9.0/bin/npm
  Browsers:
    Chrome: 102.0.5005.61
    Firefox: 100.0.2
    Safari: 15.4
    Safari Technology Preview: 15.4
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.50 
    @sveltejs/kit: next => 1.0.0-next.347 
    svelte: ^3.44.0 => 3.48.0

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: ssrp3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions