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
- Open the reproduction (or clone +
npm install + npm run dev)
- Open http://localhost:5173/web-packages/ (StackBlitz: open preview under
/web-packages/)
- Open DevTools → Network → filter
@vite/lazy
- Click "Load lazy module"
- Observe
GET /@vite/lazy?... → 404
- Open the same URL with
/web-packages inserted after the origin → 200
- Set
base: '/' → dynamic import works
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
Describe the bug
With
experimental.bundledDev: trueand a non-rootbase(e.g./web-packages), dynamicimport()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/lazywithoutbase.Notes:
base: '/'/web-packagesvite build+vite preview) under the same non-rootbaseworks — dev-onlyReproduction
https://stackblitz.com/github/dark1451/issue-vite-bundleddev-base-lazy?file=vite.config.ts
Steps to reproduce
npm install+npm run dev)/web-packages/)@vite/lazyGET /@vite/lazy?...→ 404/web-packagesinserted after the origin → 200base: '/'→ dynamic import worksnpm run build && npm run previewwithbase: '/web-packages'→ worksSystem 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.1Used Package Manager
npm
Logs
Click to expand!
Validations