Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update Vite 6 #7124

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"tinyglobby": "^0.2.10",
"tsx": "^4.19.2",
"typescript": "^5.7.3",
"vite": "^5.4.0",
"vite": "^6.0.11",
"vitest": "workspace:*",
"zx": "^8.3.0"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/vite-node/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { performance } from 'node:perf_hooks'
import { pathToFileURL } from 'node:url'
import createDebug from 'debug'
import { join, normalize, relative, resolve } from 'pathe'
import { version as viteVersion } from 'vite'
import { Debugger } from './debug'
import { shouldExternalize } from './externalize'
import { withInlineSourcemap } from './source-map'
Expand Down Expand Up @@ -392,6 +393,7 @@ export class ViteNodeServer {
return withInlineSourcemap(result, {
filepath: mod?.file || filepath,
root: this.server.config.root,
noFirstLineMapping: Number(viteVersion.split('.')[0]) >= 6,
})
}

Expand Down
5 changes: 4 additions & 1 deletion packages/vite-node/src/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function withInlineSourcemap(
options: {
root: string // project root path of this resource
filepath: string
noFirstLineMapping?: boolean
},
) {
const map = result.map
Expand Down Expand Up @@ -63,7 +64,9 @@ export function withInlineSourcemap(

// If the first line is not present on source maps, add simple 1:1 mapping ([0,0,0,0], [1,0,0,0])
// so that debuggers can be set to break on first line
if (map.mappings.startsWith(';')) {
// Since Vite 6, import statements at the top of the file are preserved correctly,
// so we don't need to add this mapping anymore.
if (!options.noFirstLineMapping && map.mappings.startsWith(';')) {
Comment on lines +67 to +69
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this check as per #6732 (comment).

map.mappings = `AAAA,CAAA${map.mappings}`
}

Expand Down
Loading
Loading