QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.48k stars 1.26k forks source link

[🐞] error during build: RollupError: Duplicate export 's_DyVc0YBIqQU' #4768

Open maiieul opened 1 year ago

maiieul commented 1 year ago

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

I accidentally added a dependency (@builder.io/qwik-react) both in devDependencies and dependencies to my package.json file, and got this obscure error message with no qwik way to know what's happening when building it for production.

This seems to happen not just for this package but for some others as well. For example, I tried with @builder.io/qwik-city and got the same error. But with @builder.io/qwik it doesn't throw anything.

I don't know if this can be fixed and I guess it's actually good to have an error message when there is a duplicate entry like that, but the current error message says "duplicate export", which led me to think that I had written two export statements somewhere in my code.

Reproduction

npm create qwik@latest

Steps to reproduce

  1. Run npm create qwik@latest
  2. Select 'Basic App' starter
  3. Manually add "@builder.io/qwik-city": "^1.2.6" to dependencies in package.json (I don't know how I ended up doing this, but I did. It was accidental.). This is the critical step to reproduce this issue. You need to have "@builder.io/qwik-city": "^1.2.6" in devDependencies and in dependencies.
  4. cd into project
  5. run npm install
  6. run npm run preview

The bug can be reproduced with npm and pnpm as well. I haven't tried it out with yarn.

System Info

System:
    OS: Linux 6.3 Fedora Linux 38 (Workstation Edition)
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i5-1340P
    Memory: 21.87 GB / 31.05 GB
    Container: Yes
    Shell: 3.6.1 - /usr/bin/fish
  Binaries:
    Node: 18.16.1 - /usr/local/bin/node
    npm: 9.7.2 - /usr/local/bin/npm
    pnpm: 8.6.7 - ~/.local/share/pnpm/pnpm
  Browsers:
    Chrome: 114.0.5735.198

Potential solutions

I think an added error message suggesting something like "You may run into this error because you have a duplicate entry in dependencies and devDependencies in package.json." may be helpful.

maiieul commented 1 year ago

P.S. The error seems to be thrown from qwikloader.ts: https://github.com/BuilderIO/qwik/blob/190f0bcd7593745b58aef07054547551253d087b/packages/qwik/src/qwikloader.ts#L85

og-dev commented 6 months ago

Same error here. Any update about this issue?

maiieul commented 6 months ago

@og-dev Are you having this error for the same reason?

gioboa commented 6 months ago

In this PR we have the same issue during the production build πŸ˜”πŸ˜’

maiieul commented 6 months ago

@gioboa @the-r3aper7 That might be related to https://github.com/BuilderIO/qwik/issues/5473

You could try linking qwik-ui in the PR branch and removing preserveModules, then build, to see if it works.

I'm in the process of cleaning-up qwik-ui's codebase, and I'll submit another PR to remove preserveModules since it's kind of a performance hack that introduces bugs (e.g. https://github.com/qwikifiers/qwik-ui/issues/519). Shai thought #5473 could be fixed quickly but that might still take another few months..