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.