vite-plugin-vue
vite-plugin-vue copied to clipboard
[Vite 3] Import a package which requires Vue causing error in production
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
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
@patak-dev it seems that this bug is related to plugin-commonjs. Thus, it should belong to Vite instead of Vue 3.
Closing as stale