Categories
TypeScript Answers

How to make web workers with TypeScript and Webpack?

Spread the love

Sometimes, we want to make web workers with TypeScript and Webpack.

In this article, we’ll look at how to make web workers with TypeScript and Webpack.

How to make web workers with TypeScript and Webpack?

To make web workers with TypeScript and Webpack, we add 'webworker' to compilerOptions.lib in tsconfig.json.

For instance, we write

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["webworker", "es5", "scripthost"]
  }
}

to add 'webworker' into compilerOptions.lib in tsconfig.json.

This will let the TypeScript compiler know that we can use web worker global variables in our project.

Conclusion

To make web workers with TypeScript and Webpack, we add 'webworker' to compilerOptions.lib in tsconfig.json.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.