Skip to content

vite 6 breaks the simple transformRequest #18824

@himself65

Description

@himself65

Describe the bug

import { createServer } from 'vite';

process.on('beforeExit', (code) => {
  console.log(code);
});

const server = await createServer({
  appType: 'spa',
  base: '/',
});

const result = await server.transformRequest('./entry.js');
const module = server.moduleGraph.getModuleById('./entry.js');
console.log('result', result);
console.log('module', module);

await server.close();

In vite 5, exit code is 0, in vite 6, it's 13

Reproduction

https://stackblitz.com/edit/stackblitz-starters-3b36p6?file=index.js

Steps to reproduce

node index.js

System Info

npx envinfo --system --npmPackages '{vite,@vitejs/*,rollup}' --binaries --browsers
Need to install the following packages:
[email protected]
Ok to proceed? (y) y


  System:
    OS: macOS 15.1.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 18.58 GB / 128.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - ~/.local/state/fnm_multishells/12350_1732795121691/bin/node
    Yarn: 1.22.22 - ~/.local/state/fnm_multishells/12350_1732795121691/bin/yarn
    npm: 10.8.2 - ~/.local/state/fnm_multishells/12350_1732795121691/bin/npm
    pnpm: 9.14.2 - ~/.local/state/fnm_multishells/12350_1732795121691/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.1.1
  npmPackages:
    vite: 6.0.1 => 6.0.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerEsbuild Dependencies Optimizationp3-minor-bugAn edge case that only affects very specific usage (priority)regressionThe issue only appears after a new release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions