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

Lots of issues in WebWorkers #6847

Closed
7 tasks done
vigneshpa opened this issue Feb 10, 2022 · 3 comments
Closed
7 tasks done

Lots of issues in WebWorkers #6847

vigneshpa opened this issue Feb 10, 2022 · 3 comments

Comments

@vigneshpa
Copy link

Describe the bug

There are many issues in WebWorkers

  • STOP generating module workers. They are not widely supported. Just generate plain workers. After all, workers don't need to be a module they can import other scripts using importScripts() even synchronously.
  • Support dynamic imports - build throws when importing dynamically even though it generates module workers 😒 . Rewrite dynamic imports using importScripts().
  • Emit asset files and other dynamically imported JS files. Right now building for production only emits the worker.js file. Stop assuming that workers don't need assets. I work with lots of binary assets and WebAssembly files.

Workarounds

Few of these issues are solvable by workarounds. For example, assets can be emitted if they are imported into the main thread code.
But many of them cannot be worked around.
I tried use importScripts() but the {type:"module"} prevents that. I have no way around it but to use webpack. 😢

I like vite. 💗
That's why I care to report.
I will be very happy if I am able to use Vite for all my projects but quirks like these make it impossible.

I like to contribute to this project but I have no free time. When I have one I will try to solve these issues.
Until then you people on the internet please try to solve 🥺 I think that they are necessary for this project.

Reproduction

https://github.com/vigneshpa/vite-wasm-worker-bug

System Info

System:
    OS: Linux 5.16 Arch Linux
    CPU: (4) x64 Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz
    Memory: 3.33 GB / 7.63 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.3.0 - /usr/bin/node
    npm: 8.4.0 - /usr/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Firefox: 96.0.3
  npmPackages:
    vite: ^2.8.0 => 2.8.0

Used Package Manager

npm

Logs

No response

Validations

@nrgnrg
Copy link

nrgnrg commented Feb 11, 2022

Support dynamic imports - build throws when importing dynamically even though it generates module workers 😒 . Rewrite dynamic imports using importScripts().

Related? #3311

@bluwy
Copy link
Member

bluwy commented Mar 7, 2022

  • STOP generating module workers. They are not widely supported. Just generate plain workers. After all, workers don't need to be a module they can import other scripts using importScripts() even synchronously.

This is fixed in #7099 (will be released in next Vite 2.9 beta)

  • Emit asset files and other dynamically imported JS files. Right now building for production only emits the worker.js file. Stop assuming that workers don't need assets. I work with lots of binary assets and WebAssembly files.

There's an incoming fix #6599


Thanks for taking the time to highlight these issues, but it would be helpful to split these up next time so we can fix them up individually. And there has been past issues for the specific points.

@bluwy bluwy closed this as completed Mar 7, 2022
@vigneshpa
Copy link
Author

Great

@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 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

4 participants