Open rhofour opened 3 years ago
I'd love this feature. We had a working version (using the second stack overflow link), but it has since become obsolete. Our application was capable of updating data across multiple tabs instantaneously through the shared worker and we should very much like that feature to remain and, if possible, become an integrated part of Angular itself.
Why not remove the worker typings from DOM and only implement them in lib.worker.d.ts?
I'd like to share some related information I discovered in case it helps anyone else. Actually maybe more relevant to #22204 in a sense, but that was declared as a duplicate of this issue so I guess it is better to continue any discussion here?
First of all, Webpack 5 has some built in features for parsing Worker syntax without any other plugins. By default this parsing works for Worker, SharedWorker, Service Worker and Node.js worker thread
To my understanding, the fact that Angular uses Webpack 5 is an "implementation detail" so I think it is not guaranteed that these features can be used forever, especially if they are not explicitly documented, but they can be more or less used right now.
I was using this feature in an Angular 13.0 app. After upgrading to Angular 13.1 it stopped working. It looks like there is recently new logic to disable Webpack 5's support when there is no webWorkerTsConfig set in angular.json, by setting parser.javascript.worker
and parser.javascript.url
to false.
This issue can be resolved by providing some kind of webWorkerTsConfig. I haven't tested it personally but I guess if you run the ng generate web-worker
command it will generate a webWorkerTsConfig
for you? And, if you do that (in Angular 13.1) you could probably tweak the code very slightly to create a SharedWorker, etc instead.
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
🚀 feature request
Relevant Package
This feature request is for @angular/cli
Description
ng generate can currently handle web-workers and service-workers, but not shared-workers. It would be very helpful if shared workers could be handled similarly.
Right now there's very little documentation about how to setup shared workers with angular, unlike web workers where I can simply call
ng generate web-worker
and start filling in my code.Describe the solution you'd like
There should be an
ng generate shared-worker
command that works similar to the commands for web and service workers.Describe alternatives you've considered
This medium article and these two Stack Overflow questions both have different solutions to make this work.