Skip to content

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

@kingyue737

Description

@kingyue737

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions