vite-plugin-vue icon indicating copy to clipboard operation
vite-plugin-vue copied to clipboard

[Vite 3] Import a package which requires Vue causing error in production

Open kingyue737 opened this issue 3 years ago • 1 comments

Describe the bug

I import vue and a 3rd package vue-virtual-scroll-list which requires vue. It works fine in dev, but raises the following error if I preview the bundle built:

Vue.component is not a function

It seems that vue is not correctly required.

This bug only exists since v3.0.0 in production.

✔️Vite v2.9.14 dev ✔️Vite v2.9.14 production ✔️Vite v3.0.4 dev ❌Vite v3.0.4 production

Reproduction

https://stackblitz.com/edit/vitejs-vite-4pp5uz

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
npmPackages:
    vite: ^3.0.2 => 3.0.4 

Used Package Manager

pnpm

Logs

No response

Validations

kingyue737 avatar Aug 01 '22 07:08 kingyue737

@patak-dev it seems that this bug is related to plugin-commonjs. Thus, it should belong to Vite instead of Vue 3.

kingyue737 avatar Dec 13 '22 08:12 kingyue737

Closing as stale

kingyue737 avatar Jul 10 '24 08:07 kingyue737