Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Worker that imports sth from vendor chunk #3041

Closed
maccesch opened this issue Apr 18, 2021 · 5 comments
Closed

Issue with Worker that imports sth from vendor chunk #3041

maccesch opened this issue Apr 18, 2021 · 5 comments

Comments

@maccesch
Copy link

Describe 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

@Niputi
Copy link
Contributor

Niputi commented Apr 18, 2021

try following this comment #2618 (comment)

@maccesch
Copy link
Author

Thanks for the tip! Unfortunately it didn't change anything in my case.

@milomg
Copy link
Contributor

milomg commented Apr 20, 2021

Maybe try adding ?worker&inline or #2494

@bluwy
Copy link
Member

bluwy commented Mar 6, 2022

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.

@bluwy bluwy closed this as completed Mar 6, 2022
@patak-dev
Copy link
Member

We are no longer splitting the vendor chunk by default, so that may be the reason it works now

@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants