I need to use web-workers for heavy computation and Angular provides a convenient way to generate a web-worker in an application with the CLI command ng generate web-worker app
.
The issue is, when built in production using ng build --prod
, the generated web-worker bundle doesn't appear to be well optimized. I still can find whole variable, class or method names in the file, and some parts of the code is easy to read on the bundle, which struggles me.
Is there a way to better minify that code?
Regards,
EDIT: To give an example, here is the content of app.worker.ts:
/// <reference lib="webworker" />
class MyClassName{
myMethodName(){}
}
const myVariableName = new MyClassName()
postMessage(myVariableName.myMethodName());
And this can be found inside the worker.js file generated with ng build --prod
const myVariableName=new class{myMethodName(){}};postMessage(myVariableName.myMethodName())}});
the code is optimized but is still easy to read.
EDIT 2: typo
After some research, it seems like it's intended that webworker files, like service-worker files, are unminified.
Minification can be made manually as explained here