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
edit your angular.json
and set optimization:true
https://angular.io/guide/workspace-config#build-configs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With