Search code examples
angulartypescriptweb-worker

Splitting a Web-Worker in several Typescript files in Angular2+


I run some Typescript code on a Web-Worker using the file-loader given on this page and it works as expected in my Angular 6 app.

For a better readability and maintainability of the code running on the Web-Worker, I need to split it in several Typescript (.ts) files.

I already tryied using require('worker!...') or importScripts('filename.js'), but i didn't manage to get them work with a Typescript (.ts) file. If possible, I would prefer an integrated build system the same way we import a Service in Angular2+.

Any help would be appreciated, Regards.


Solution

  • I finally choose to implement platform-webworker in angular 6 using angular-cli-builders

    Solution explained here: https://github.com/meltedspark/angular-builders/issues/13