-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
[Vue3] build + watch + sourcemap cause rollup conflicting error #35
Comments
Same here :( |
Facing the same issue as described in the report. |
@Chen-jj I found a workaround for this - just use |
Same issue :( watching with sourcemap is not possible currently with vite (?) |
Maybe in vite 5 will be fix for this. I |
Same problem ( |
I don't know if it's related, but there are similar errors even when not in watch mode in certain cases -- specifically for mac and linux platforms. |
I also ran into this issue today randomly and have some maybe useful information after a lot of trial and error: Versions im running
I have 3 build scripts for each env
i have some env based config so i need to know which env its being built, so i have the NODE_ENV defined for each. After some time I discovered that this issue was only happening when building for dev and staging envs, production would always work with no issues. After some more investigation I figured out that without the My guess is that there's some behaviour somewhere under the hood (vite, rollup, some other dependecy) that there's some bundling that happens that does/doesn't take into account NODE_ENV? |
Same problem ( |
We started seeing this as well after upgrading a lot of dependencies. I upgraded our deps one by one until I have narrowed it to:
I tried it happens in random files in each build. Changing a file content a little bit makes it pass the file it was failing at but it fails in another one.
I can confirm this, passing |
Same issue here, but also with |
Edit: Here is a workaround function vueNoCachePlugin() {
let config
return {
name: 'vue-no-cache',
configResolved(resolvedConfig) {
config = resolvedConfig
},
shouldTransformCachedModule({ id }) {
// `vite build --watch`
// always transform cached modules for vue sfc
if (
config.command === 'build' &&
config.build.watch &&
config.build.sourcemap &&
id.includes('.vue')
) {
return true
}
return false
}
};
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueNoCachePlugin()
],
build: {
sourcemap: true,
},
});
|
This hit me twice over several months on separate projects, where I forgot about the workaround the first time 🤦♂️ and had to troubleshoot all over again. Problem: vite watch mode builds properly, then logs "Multiple conflicting contents for sourcemap..." after you force a rebuild (even by adding a blank line to a Workaround: Disable @edison1105's PR looks simple (just a few lines). Hopefully a maintainer can review and merge for an upcoming minor/patch release. |
Describe the bug
vite build --watch
<template>
ofApp.vue
Multiple conflicting contents for sourcemap source /home/projects/vitejs-vite-4gfbyh/src/App.vue
Every build when rollup calls
addModuleSource
method to process modules, it will figure out should use cache or not:https://github.com/rollup/rollup/blob/27c0557f904321d649c9bd85f6fb670ca5700427/src/ModuleLoader.ts#L271-L275
During the second build which caused by the change of vue
<template>
, module/some_paths/index.vue?vue&type=script&lang.ts
comes inaddModuleSource
method.ButcachedModule.originalCode === sourceDescription.code
is true this time, so rollup uses the cached version of this vue script module.Finally, sourcemap source of module
/some_paths/index.vue?vue&type=script&lang.ts
isold template + old script
, while sourcemap source of module/some_paths/index.vue
isnew template + old script
.Becasue they all have the same sourcefilename but having different source contents, thus the error comes from traceMappings method of rollup:
https://github.com/rollup/rollup/blob/69ff4181e701a0fe0026d0ba147f31bc86beffa8/src/utils/collapseSourcemaps.ts#L87-L89
Reproduction
https://stackblitz.com/edit/vitejs-vite-4gfbyh?file=vite.config.js
System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: