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

Getting "Multiple conflicting contents for sourcemap source" when trying to build app with rc.10 #14981

Closed
Bodokh opened this issue Sep 20, 2022 · 29 comments

Comments

@Bodokh
Copy link

Bodokh commented Sep 20, 2022

Environment


  • Operating System: Darwin
  • Node Version: v14.19.3
  • Nuxt Version: 3.0.0-rc.10
  • Nitro Version: 0.5.3
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: alias, app, env, server, build, css, modules, ignore, publicRuntimeConfig, runtimeConfig, vite, storybook
  • Runtime Modules: @pinia/nuxt@0.4.2, @vueuse/nuxt@9.2.0, @nuxtjs/tailwindcss@5.3.3, ./modules/fonts/index.ts
  • Build Modules: -

Reproduction

I am unable to reproduce this, I only hope you might know how this sort of error can arrise. The error happens in multiple versions of node, i checked versions: 14, 16, 18

EDIT:

I can confirm the issue does not happen on rc.9.

Describe the bug

I have a project that works when using yarn dev, but when i try to build i get the following error:
Multiple conflicting contents for sourcemap source /somepath/pages/vue-page.vue

I tried deleting the page and building but it just threw the same error for another page and so on for all pages.

The build was working when I was using rc.6 beforehand.

Additional context

No response

Logs

ERROR  Multiple conflicting contents for sourcemap source /path/pages/user/profile.vue                                                                                                                 16:06:31


 ERROR  Multiple conflicting contents for sourcemap source /path/pages/user/profile.vue                                                                                                                 16:06:31

  at error (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
  at Link.traceMappings (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:13934:32)
  at collapseSourcemaps (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14027:63)
  at Chunk.render (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14896:19)
  at processTicksAndRejections (internal/process/task_queues.js:95:5)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16006:40
  at async Promise.all (index 109)
  at async Bundle.addFinalizedChunksToBundle (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16004:9)
  at async Bundle.generate (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:15984:13)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:23754:27

Another Log

  at error (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
  at Link.traceMappings (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:13934:32)
  at collapseSourcemaps (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14027:63)
  at Chunk.render (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14896:19)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16006:40
  at async Promise.all (index 116)
  at async Bundle.addFinalizedChunksToBundle (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16004:9)
  at async Bundle.generate (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:15984:13)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:23754:27
  at async catchUnfinishedHookActions (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:23088:20)
  at async doBuild (node_modules/vite/dist/node/chunks/dep-557f29e6.js:45822:20)
  at async Module.build (node_modules/vite/dist/node/chunks/dep-557f29e6.js:45653:16)
  at async buildServer (node_modules/@nuxt/vite-builder/dist/shared/vite-builder.cbd4a916.mjs:589:5)
  at async bundle (node_modules/@nuxt/vite-builder/dist/shared/vite-builder.cbd4a916.mjs:825:3)
  at async build (node_modules/nuxt/dist/index.mjs:1992:5)
  at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:46:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
@danielroe
Copy link
Member

Would you provide a reproduction? 🙏

@ShaggyTech
Copy link

ShaggyTech commented Sep 20, 2022

I had the same issue and solved it temporarily by adding this to my nuxt.config:

sourcemap: {
  server: false,
  client: false,
},

@danielroe This is not really a 'minimal' reproduction but maybe it will help:

Stackblitz
Repo (branch: sourcemap-errors)

Running 'yarn build' will produce similar errors as to what @Bodokh described.

@daniluk4000
Copy link
Contributor

I'm getting the same error with RC 11

@ShaggyTech
Copy link

So I did some more debugging with the reproduction I shared. In my particular case there is only one component causing this issue - CardGroup.vue .

  1. If CardGroup component is not used then error goes away and build is successful, indicating this is the only component involved in the error.

  2. Removing the <script>...</script> from CardGroup.vue will make the error go away and build is successful. I'm only using it to name the component in this instance.

  3. Removing xl:(grid-cols-4 mt-20 px-8) windi class from CardGroup.vue#L7 makes the error go away and build is successful.

Doing either 2 or 3 independently will make the error go away.

To clarify the above:

  • <script> and no windi class = OK
  • windi class and no <script> = OK
  • <script> and windi class = ERROR

I put a breakpoint at Link.traceMappings (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:13934:32) which is where the error is thrown.

class Link {
 ...
   traceMappings() {
    ...
 **   else if (content != null && sourcesContent[sourceIndex] !== content) {
        return error({
            message: `Multiple conflicting contents for sourcemap source ${filename}`
        });
    }
   ...
}

I noticed there is a difference in content and sourcesContent[sourceIndex] variables which triggers the error. I'm combining my classes via windicss such as xl:(mt-10 pt-10). Variable sourcesContent[sourceIndex] has them separated like xl:mt-10 xl:pt-10 (maybe a part of the windi build process?), but this does not match content which retains original string like xl:(mt-10 pt-10).

What doesn't make sense is that I use these same windi class combinators in other components and they are fine. Also, why does removing the script and keeping the windi class build successfully?

This is about as far as I got and it's a weird one, but hopefully this provides some help in resolving the issue.

@danielroe
Copy link
Member

It's definitely a weird one. Is anyone else with this issue using windicss or something similar?

@daniluk4000
Copy link
Contributor

@danielroe I'm not using any. Here's dependencies list. I have no clue what's with that problem. Workaround with disabling source maps resolved the issue for me temporaly.

изображение

@toooni
Copy link
Sponsor

toooni commented Sep 22, 2022

I do have the same issue with rc.11 and it seems like <client-only></client-only> is the problem.

@zavvla
Copy link

zavvla commented Sep 22, 2022

I have this problem too.

ERROR  Multiple conflicting contents for sourcemap source 
/Users/zavvla/Work/some/pages/questions/index.vue                                                      15:50:06

  at error (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
  at Link.traceMappings (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:13934:32)
  at collapseSourcemaps (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14027:63)
  at Chunk.render (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:14896:19)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16006:40
  at async Promise.all (index 31)
  at async Bundle.addFinalizedChunksToBundle (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:16004:9)
  at async Bundle.generate (node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:15984:13)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:23754:27

@toooni
Copy link
Sponsor

toooni commented Sep 22, 2022

@zavvla Do you use <client-only/> blocks in there? If yes, can you try what happens if you remove it/them.

@zavvla
Copy link

zavvla commented Sep 22, 2022

@zavvla Do you use <client-only/> blocks in there? If yes, can you try what happens if you remove it/them.

yes, it fixed problem

Copy link
Member

Would you check whether setting experimental.treeshakeClientOnly to false works around the issue for you?

@toooni
Copy link
Sponsor

toooni commented Sep 22, 2022

I've added experimental: { treeshakeClientOnly: true }, to nuxt.config.js and the build still failed.

@ShaggyTech
Copy link

ShaggyTech commented Sep 24, 2022

I did some more investigation tonight.

  • Removed all <ClientOnly> from the app = still errors
  • Tried setting experimental.treeshakeClientOnly to false = still errors

I found that this commit introduced the error: nuxt/framework@eab4706

The commit preceding that one does not error on build: nuxt/framework@ec21019

You can test by using the following nuxt versions:

  • "nuxt": "npm:nuxt3@3.0.0-rc.10-27709172.ec21019" has no errors
  • "nuxt": "npm:nuxt3@3.0.0-rc.10-27709178.eab4706" has sourcemap errors

This change to Vite maybe related?

@danielroe
Copy link
Member

Thanks for the debugging @ShaggyTech. The reason that commit triggers it is that previously, vite.build.sourcemap was set to false by default, and that is probably the best workaround for now i you are experiencing this. (You can also set sourcemap to false, but that will also disable nitro sourcemaps, which you may wish to have.)

As for the cause, it seems like it might possibly be an upstream vite issue that is triggered by the interactions between vite plugins. It is triggered in the reproduction here, if I can tell correctly, by a sourcemap generated by components loader plugin not including the changes to classes, as you note above.

@danielroe danielroe added the vite label Sep 27, 2022
@yeonjulee1005
Copy link
Sponsor

The same symptom occurs in rc.12 version and the build and generate fails. T.T ..
Please check problem.

@andysay
Copy link

andysay commented Nov 6, 2022

also have it .rc13

if use client-only , and component have .client prefix will be brake , need use only .client prefix will be ok.

@manniL
Copy link
Member

manniL commented Nov 6, 2022

also have it .rc13

if use client-only , and component have .client prefix will be brake , need use only .client prefix will be ok.

If you think that is a new problem, then please create a new issue ☺️

@gabjauf
Copy link

gabjauf commented Nov 10, 2022

Same issue on .rc13
It looks related to the <client-only/>
Build fails when 2 or more <client-only/> are present in code with the following error Multiple conflicting contents for sourcemap source targeting one of the files containing it.

Build works when

  • None or 1 <client-only/> present in the whole codebase OR
  • experimental: { treeshakeClientOnly: false } in nuxt.config.ts

@cyprianwaclaw
Copy link

Same issue on .rc13 and rc. 11

@mehotkhan
Copy link

Same issue on "nuxt": "3.0.0",

@ialhashim
Copy link

ialhashim commented Jan 8, 2023

Same issue caused when using multiple ClinetOnly (e.g. ImgComparisonSlider). This fixed it for me:

export default defineNuxtConfig({
    experimental:{
        treeshakeClientOnly: false
    }
})

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
ky28059 added a commit to gunn-elimination/elimination-2023 that referenced this issue Jan 22, 2023
@paperplane110
Copy link

paperplane110 commented Mar 8, 2023

It's definitely a weird one. Is anyone else with this issue using windicss or something similar?

Meet the same issue here. I use nuxt: "^3.0.0-rc.14" and "nuxt-windicss": "^2.5.5".
The yarn generate command will failed when I try to add some screen variants , such as <md, to my ProseCode component. Once I remove the <md, build is successful

So I wrote these styles in pure css, the error is gone. It seems like there is something wrong with nuxt-windicss.

@danielroe
Copy link
Member

Is this still reproducible for anyone here with Nuxt v3.3.2? There have been some improvements upstream in Vite.

@baronkoko
Copy link

baronkoko commented Mar 29, 2023

@danielroe in Nuxt v3.3.2 this problem is gone on my end, thanks 🙏

@MichaelNussbaumerGOWEST
Copy link

On my end it fails with nuxt v3.3.3 if I use ssr: true

@danielroe
Copy link
Member

@MichaelNussbaumerGOWEST Could you provide a reproduction? 🙏

@Soya-xy
Copy link

Soya-xy commented May 11, 2023

@danielroe when i run pnpm run build/generate Nuxt 3.4.3 also not work
reproduction: https://github.com/Soya-xy/nuxt3-editor
image

@ShaggyTech
Copy link

ShaggyTech commented May 15, 2023

I revisted my reproduction I posted in an earlier comment. Repo for my project is at https://github.com/ShaggyTech/dubsquared.

I'm now on Nuxt v3.4.3 with Nitro v2.3.3. I still receive the sourcemap error when trying to build the app via nuxt build.

I can make the error go away now by turning off server sourcemap in the nuxt config like so:

sourcemap: {
  server: false,
},

Previously I was also disabling client sourcemaps but the problem now seems isolated to only the server build, it does not error until the server build happens, client build is successful in any case.

The following is the error and trace I'm getting:

 ERROR  Multiple conflicting contents for sourcemap source /home/shaggy/git-repos/nuxt3/dubsquared/components/Layout/Page/Footer/CardGroup.vue 

  at error (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:2125:30)
  at Link.traceMappings (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17163:32)
  at collapseSourcemaps (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17247:63)
  at transformChunk (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17342:15)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17386:17
  at async Promise.all (index 50)
  at async transformChunksAndGenerateContentHashes (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17382:5)
  at async renderChunks (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17292:109)
  at async Bundle.generate (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17510:13)
  at async node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:25802:27
  at async catchUnfinishedHookActions (node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:24889:20)
  at async Module.build (node_modules/vite/dist/node/chunks/dep-a178814b.js:46426:22)
  at async buildServer (node_modules/@nuxt/vite-builder/dist/shared/vite-builder.1d3e962a.mjs:845:5)
  at async bundle (node_modules/@nuxt/vite-builder/dist/shared/vite-builder.1d3e962a.mjs:1155:3)
  at async build (node_modules/nuxt/dist/index.mjs:3175:5)
  at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:55:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:48:20)

Output from npx nuxi info:

Nuxt project info:                                                                                                                                                         4:45:00 PM

------------------------------
- Operating System: Linux
- Node Version:     v18.13.0
- Nuxt Version:     3.4.3
- Nitro Version:    2.3.3
- Package Manager:  yarn@3.3.1
- Builder:          vite
- User Config:      sourcemap, imports, css, runtimeConfig, modules, build, pwa, vite, vueuse, windicss
- Runtime Modules:  @formkit/nuxt@0.16.5, @kevinmarrec/nuxt-pwa@0.17.0, @pinia/nuxt@0.4.9, @vueuse/nuxt@10.1.0, @vueuse/motion/nuxt@2.0.0-beta.27, nuxt-windicss@2.6.1, unplugin-icons/nuxt, ~/modules/sitemap
- Build Modules:    -
------------------------------

@danielroe
Copy link
Member

@ShaggyTech Checking this again, the issue seems to stem from windicss, which is generating invalid sourcemaps:

https://github.com/windicss/vite-plugin-windicss/blob/main/packages/vite-plugin-windicss/src/index.ts#L168-L173

When this is addressed the issue goes away. Would you open an issue in their repo? 🙏

@Soya-xy I couldn't reproduce the issue with your repo. Possibly you might have resolved it upstream.

I'm closing this issue as it doesn't seem to be an issue in Nuxt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests