Closed Kolobok12309 closed 2 years ago
Connected repo with minimal library https://github.com/kolobok12309/vite-library-bug-double-load
I think this is a duplicate of #3910. The workaround for now is to add that library, e.g. vite-library-bug-double-load
, to optimizeDeps.exclude
, and if there's any CJS deps used by that library, it needs to be re-added to optimizeDeps.include
, e.g. vite-library-bug-double-load > cjs-dep
.
@bluwy, you are right, is duplicate, i didn't see this issue. But optimizeDeps.exclude: ['shared']
don't work for this minimal repro
Describe the bug
We write some library with
.vue
components and utils (for this components and other). This utils can have some state, and methods for change it(keys is symbols). In real project with vite(Nuxt3 setup) we found duplication of imported modules(by console.log)This problem from
vite
or vue-plugin, can't say for sure, sometimes module load 2 times, sometimes 3, and this critical because we use symbolsProblem is similar to #7323
In repro duplicates is
/node_modules/.vite/deps/chunk-VQ4VIJMT.js?v=3a551489
and/node_modules/shared/shared.js
.vue file is initiator ofshared.js
, and simple.js
is initiator ofchunk-VQ4VIJMT.js?v=3a551489
fileReproduction
https://github.com/Kolobok12309/vitejs-double-file-load
System Info
Used Package Manager
yarn
Logs
No response
Validations