Skip to content

Conversation

@jiji-hoon96
Copy link
Contributor

Description

#20853

Fixes inconsistent file field in sourcemaps when preload code is injected.

This happened because combineSourcemaps() overwrites the file field with chunk.fileName, which includes the assets/ directory.

Solution

Preserve the original chunk.map.file value after combining sourcemaps to maintain consistency with Rollup/Rolldown behavior.

Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

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

The code seems correct, but checking locally, the same test is passing without the patch. I'm not sure what's different from the original reproduction though. Can you look into it?

@jiji-hoon96
Copy link
Contributor Author

hi @hi-ogawa

In my local environment, the test fails without the patch. Have you tried re-build or clearing the cache?

Without patch

$ cat dist/assets/after-preload-dynamic-*.js.map | jq '.file'
"assets/after-preload-dynamic-Cq8pjAOL.js" # Wrong

Test Result => FAIL: expected 'assets/after-preload-dynamic-Cq8pjAOL.js' not to match /^assets//

Apply patch

$ cat dist/assets/after-preload-dynamic-*.js.map | jq '.file'
"after-preload-dynamic-Cq8pjAOL.js" # Success

Test Result => Success

@hi-ogawa
Copy link
Contributor

Oh weird. Right, I was able to confirm. 👍 Sorry, I thought I double checked the build, but probably I was running unrelated tests.

hi-ogawa
hi-ogawa previously approved these changes Oct 14, 2025
@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) feat: sourcemap Sourcemap support labels Oct 14, 2025
@sapphi-red sapphi-red enabled auto-merge (squash) October 14, 2025 12:55
@sapphi-red sapphi-red merged commit c714776 into vitejs:main Oct 14, 2025
17 of 18 checks passed
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Oct 15, 2025
| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | vite    | 7.1.9 | 7.1.10 |


## [v7.1.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-7110-2025-10-14-small)

##### Bug Fixes

- **css:** avoid duplicate style for server rendered stylesheet link and client inline style during dev ([#20767](vitejs/vite#20767)) ([3a92bc7](vitejs/vite@3a92bc7))
- **css:** respect emitAssets when cssCodeSplit=false ([#20883](vitejs/vite#20883)) ([d3e7eee](vitejs/vite@d3e7eee))
- **deps:** update all non-major dependencies ([879de86](vitejs/vite@879de86))
- **deps:** update all non-major dependencies ([#20894](vitejs/vite#20894)) ([3213f90](vitejs/vite@3213f90))
- **dev:** allow aliases starting with `//` ([#20760](vitejs/vite#20760)) ([b95fa2a](vitejs/vite@b95fa2a))
- **dev:** remove timestamp query consistently ([#20887](vitejs/vite#20887)) ([6537d15](vitejs/vite@6537d15))
- **esbuild:** inject esbuild helpers correctly for esbuild 0.25.9+ ([#20906](vitejs/vite#20906)) ([446eb38](vitejs/vite@446eb38))
- normalize path before calling `fileToBuiltUrl` ([#20898](vitejs/vite#20898)) ([73b6d24](vitejs/vite@73b6d24))
- preserve original sourcemap file field when combining sourcemaps ([#20926](vitejs/vite#20926)) ([c714776](vitejs/vite@c714776))

##### Documentation

- correct `WebSocket` spelling ([#20890](vitejs/vite#20890)) ([29e98dc](vitejs/vite@29e98dc))

##### Miscellaneous Chores

- **deps:** update rolldown-related dependencies ([#20923](vitejs/vite#20923)) ([a5e3b06](vitejs/vite@a5e3b06))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: sourcemap Sourcemap support p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants