Skip to content

Do not use fs injection for bundled dev mode on Vite 8.1+ #386

Description

@liangmiQwQ

Describe the bug

When enable bundled dev mode in Vite 8.1+ (Also known as full bundle mode), we cannot ask Vite to read files on disk anymore.

At the same time, Vite devtools will inject the scrips to html file with a @fs URL.

transformIndexHtml() {
const fileUrl = process.env.VITE_DEVTOOLS_LOCAL_DEV
? normalize(join(dirDist, '..', 'src/client/inject/index.ts'))
: normalize(join(dirDist, 'client/inject.js'))
return [
{
tag: 'script',
attrs: {
src: `/@fs/${fileUrl}`,
type: 'module',
},
injectTo: 'body',

It will make Vite devtools stop working after upgrading.

@fs//Users/liangmi/code/liangmiQwQ/simple-introduce/node_modules/.pnpm/@vitejs+devtools@0.3.3_typescript@5.9.3_vite@8.1.0/node_modules/@vitejs/devtools/dist/client/inject.js:1  Failed to load resource: the server responded with a status of 404 (Not Found)

Reproduction

https://github.com/liang-demos/vite-devtools-bundled-dev-reproduction

System Info

System:
    OS: macOS 26.5.1
    CPU: (15) arm64 Apple M5 Pro
    Memory: 1.07 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.12.0 - /Users/liangmi/.vite-plus/js_runtime/node/24.12.0/bin/node
    Yarn: 1.22.22 - /Users/liangmi/.vite-plus/bin/yarn
    npm: 11.6.2 - /Users/liangmi/.vite-plus/js_runtime/node/24.12.0/bin/npm
    pnpm: 11.4.0 - /Users/liangmi/.vite-plus/bin/pnpm
    bun: 1.4.0 - /Users/liangmi/.bun/bin/bun
  Browsers:
    Chrome: 148.0.7778.216
    Safari: 26.5

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions