Enabling modulePreload results in incorrect sourcemaps after the preload code #12047
Closed
7 tasks done
Labels
p3-minor-bug
An edge case that only affects very specific usage (priority)
Describe the bug
When
build.modulePreload
is enabled in the vite config, the sourcemaps for the generated bundle are incorrect after the location of the inserted preload code (source is here, I believe). The sourcemaps for any code before the preload script in the generated bundle are correct.When disabling
modulePreload
by setting the config to false, the sourcemaps are correct. Enabling the modulePreloading, but disabling the polyfill results in the incorrect sourcemaps.It seems that there needs to be multiple chunks for the issue to happen. In the reproduction repo,
utils.ts
file was added to create another chunk, though using thesplitVendorChunkPlugin
will also cause the issue.Reproduction
https://github.com/JosNun/vite-modulepreload-sourcemap-issue
Steps to reproduce
npm install
vite build --mode=production
vite preview
Clicking the "throw an error" button will cause an exception. The sourcemapped line in devtools points to the wrong line (and in this case, file) in the code when module preloading is enabled.
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: