Search code examples
typescriptweb-worker

How to import libraries in a web-worker using typescript


I want to load an extension-like code in a web worker but I need to import external libraries to the code. The problem is that the typescript compiler does not generate valid code for the web worker. The best solution that I have is to construct the Worker with type module, in that way i can use es6 modules inside the worker but I have to use chrome beta version with the flag --enable-experimental-web-platform-features in order to get it working. I want to know if there is a way to achieve that.


Solution

  • I just got this working by using webpack, because webpack can put everything in one bundle I do not have to import anything from external resources.