WebWorkers problem in Angular related to Vite optimizeDeps
#28994
Labels
angular/build:application
area: @angular/build
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Command
serve
Is this a regression?
The previous version in which this bug was not present was
No response
Description
We have a library that utilizes web workers. It employs the new Worker interface:
We have successfully consumed the lib in various scenarios, whether based on Webpack or Vite. See the examples below:
When integrating into a Vite-based framework, a warning appears regarding one of the dependencies. This is a known issue in Vite, specifically with esbuild. To resolve this, we should add the library to
optimizeDeps
in the Vite config - recommended by vite maintainers, which works well.I attempted to integrate a poc of the same library in Angular and encountered a similar warning. I tried customizing Vite but faced a limitation, as there is no way to override
optimizeDeps
in Angular, as noted here.In some threads, I see that setting
removes the warning above, but then the worker is requested from an incorrect path.
I also have tried the following
still no success
Minimal Reproduction
This is basically minimal repo for reproduction
commands to run
Exception or Error
Your Environment
Anything else relevant?
I want to emphasize that other Vite-based implementations for Vue, React, and Quasar work, so it's only Angular that's not working.
In addition, the
npm run build
also does not work and tries to load the worker from a wrong path (Again the build with vite, and webpack works)The text was updated successfully, but these errors were encountered: