Issue with Worker that imports sth from vendor chunk
See original GitHub issueDescribe the bug
Everything works perfectly while developing. But after building I get
Uncaught ReferenceError: global is not defined
at vendor.f5fc9a77.js:31
Tracking down the error shows that it has to do with popper.js which is used by v-tooltip. Obviously it is not meant to be used in a worker context. But because the worker imports another library, which is also built into the vendor chunk, it is being executed on the worker.
Reproduction
Here you can find a minimal project reproducing the issue. v-tooltip is used in some component and the worker imports another library (doesn’t matter which one).
https://gitlab.com/synphonyte/viteWorkerIssue
Run vite build
and serve the resulting files in folder dist
. You will the see the above mentioned error in the browsers dev tools.
System Info
Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:
System:
OS: macOS 11.2.3
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 109.63 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.14.0 - ~/.nvm/versions/node/v14.14.0/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v14.14.0/bin/npm
Browsers:
Chrome: 89.0.4389.128
Firefox: 87.0
Firefox Nightly: 85.0a1
Safari: 14.0.3
npmPackages:
@vitejs/plugin-vue: ^1.2.1 => 1.2.1
vite: ^2.1.5 => 2.1.5
Used package manager: yarn
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
We are no longer splitting the vendor chunk by default, so that may be the reason it works now
I can’t seem to reproduce this. The repro worked fine for me without any errors, perhaps something was fixed in
popperjs
? Or perhaps the recent web workers improvement in Vite had fixed this. I’ll close this for now, but feel free to let me know if the issue still persists and provide a repro along side.