Skip to content

bundledDev + non-root base: dynamic import requests /@vite/lazy without base → 404 #23216

Closed

Description

@dark1451

Describe the bug

With experimental.bundledDev: true and a non-root base (e.g. /web-packages), dynamic import() in dev requests:

/@vite/lazy?id=...&clientId=...

instead of:

/web-packages/@vite/lazy?id=...&clientId=...

Because the path omits config.base, Vite's base middleware returns 404 ("did you mean /web-packages/@vite/lazy?...").

Expected: lazy proxy URL is prefixed with base.
Actual: hardcoded /@vite/lazy without base.

Notes:

  • Works with base: '/'
  • Works if the URL is manually rewritten to include /web-packages
  • Production (vite build + vite preview) under the same non-root base works — dev-only

Reproduction

https://stackblitz.com/github/dark1451/issue-vite-bundleddev-base-lazy?file=vite.config.ts

Steps to reproduce

  1. Open the reproduction (or clone + npm install + npm run dev)
  2. Open http://localhost:5173/web-packages/ (StackBlitz: open preview under /web-packages/)
  3. Open DevTools → Network → filter @vite/lazy
  4. Click "Load lazy module"
  5. Observe GET /@vite/lazy?... → 404
  6. Open the same URL with /web-packages inserted after the origin → 200
  7. Set base: '/' → dynamic import works
  8. npm run build && npm run preview with base: '/web-packages' → works

System Info

System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 189.64 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.21.1 - /Users/theo/.nvm/versions/node/v22.21.1/bin/node
    Yarn: 3.6.1 - /Users/theo/.nvm/versions/node/v22.21.1/bin/yarn
    npm: 10.9.4 - /Users/theo/.nvm/versions/node/v22.21.1/bin/npm
    pnpm: 10.9.0 - /Users/theo/.nvm/versions/node/v22.21.1/bin/pnpm
  Browsers:
    Chrome: 151.0.7922.108
    Safari: 18.3
  npmPackages:
    @vitejs/plugin-react: ^6.0.4 => 6.0.5 
    vite: ^8.2.0 => 8.2.1

Used Package Manager

npm

Logs

Click to expand!
# Network / terminal
GET /@vite/lazy?id=...&clientId=... → 404
# baseMiddleware suggests: /web-packages/@vite/lazy?...

Validations

Activity

  1. added theissue type on Aug 10, 2026
  2. AbarnaaSree commented on Aug 10, 2026

    @AbarnaaSree

    Hi, I’d like to investigate and work on this issue if no one is currently working on it. I can reproduce the problem with experimental.bundledDev: true and a non-root base, where the generated /@vite/lazy request misses the configured base path and results in a 404.

    Would it be okay for me to work on a fix and submit a PR?

  3. h-a-n-a commented on Aug 11, 2026

    @h-a-n-a
    Member

    Hi, I’d like to investigate and work on this issue if no one is currently working on it. I can reproduce the problem with experimental.bundledDev: true and a non-root base, where the generated /@vite/lazy request misses the configured base path and results in a 404.

    Would it be okay for me to work on a fix and submit a PR?

    Yes! Go ahead! Thanks for the contribution

  4. added
    p2-edge-case
    and removed on Aug 13, 2026
  5. self-assigned this
    on Oct 15, 2026
  6. locked and limited conversation to collaborators on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feat: bundled-devp2-edge-case

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions