Skip to content

Vite base option not working with RSC module loading in browserΒ #582

@pawelblaszczyk5

Description

@pawelblaszczyk5

Related plugins

Describe the bug

Hello πŸ‘‹

It seems like the base option with Vite results in invalid chunk loading in browser environment:

Image

For /src/client.tsx request goes to http://localhost:5173/examplesrc/client.tsx - while debugging I found this:

return __vite_rsc_raw_import__(import.meta.env.BASE_URL + id.slice(1))

It seems like there's a slice(1) call for some reason. If I locally patched it to remove the slice - it works correctly, but I'm not sure why it was there in the first place πŸ˜„

I hope my investigation is helpful, thanks a lot in advance!

Reproduction

https://github.com/pawelblaszczyk5/rsc-base-reproduction

Steps to reproduce

  1. Start with RSC default starter
  2. Add base option to vite.config.ts
  3. Run dev server, observe the error of loading client chunk in browser

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 130.72 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.4.0 - ~/.local/state/fnm_multishells/2224_1752770938234/bin/node
    npm: 11.4.2 - ~/.local/state/fnm_multishells/2224_1752770938234/bin/npm
    pnpm: 10.13.1 - ~/.local/state/fnm_multishells/2224_1752770938234/bin/pnpm
    bun: 1.1.33 - ~/.bun/bin/bun
  Browsers:
    Chrome: 138.0.7204.101
    Edge: 120.0.2210.121
    Safari: 18.5
  npmPackages:
    @vitejs/plugin-react: latest => 4.6.0 
    @vitejs/plugin-rsc: latest => 0.4.12 
    vite: ^7.0.4 => 7.0.5

Used Package Manager

pnpm

Logs

N/A here

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