-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Description
Describe the bug
When Vite SSR transforms file that has source map with multiple sources, only a single entry is returned in the final source map's sources. This causes issues in Vitest: vitest-dev/vitest#6120
With source map like
{
"version": 3,
"file": "bundle.js",
"sources": [
"./first.ts",
"./second.ts"
],
"sourcesContent": [
"...",
"..."
],
"names": [
"covered",
"uncovered"
],
"mappings": "..."
}... Vite returns map with sources: ["./first.ts"]. The "./second.ts" is dropped during SSR transform.
Reproduction
https://stackblitz.com/~/edit/vitejs-vite-fj3cj8
Steps to reproduce
pnpm install
pnpm run build # Create a bundle with Rollup
pnpm run start # Calls "node ./server.mjs" which runs Vite via Node API
const ssr = await server.transformRequest("./dist/bundle.js", { ssr: true });
const web = await server.transformRequest("./dist/bundle.js", { ssr: false });
console.log({ ssr: ssr.map.sources, web: web.map.sources });{
ssr: [ '../src/first.ts' ], // <-- Missing '../src/second.ts'
web: [ '../src/first.ts', '../src/second.ts' ]
}System Info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M2
Memory: 74.52 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.15.0/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
pnpm: 9.4.0 - ~/.nvm/versions/node/v20.15.0/bin/pnpm
Browsers:
Chrome: 126.0.6478.127
Safari: 17.5
npmPackages:
@vitejs/release-scripts: ^1.3.1 => 1.3.1
rollup: ^4.13.0 => 4.13.0
vite: workspace:* => 5.3.3Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.