[BUG] TerserPlugin breaks $parents["typeName"] functionality #1142
Description
Environment
Provide version numbers for the following components (information can be retrieved by running tns info
in your project folder or by inspecting the package.json
of the project):
-
CLI: 6.7.4
-
Cross-platform modules: 6.5.8
-
Android Runtime: 6.5.1
-
iOS Runtime: 6.5.1
-
Plugin(s):
-
Node.js: 12.16.3
-
Please, attach your package.json and webpack.config.js as these configurations are usually critical for investigating issues with webpack
Describe the bug
When using --env.uglify, Terser Plugin minifies class and function names. As a result, NativeScript's $parents[] references inside XML files are broken since they use component class names to get distant parent (e.g. $parents["Frame"]).
All in all, after minimizing, 'Frame' will be called 'e' but $parents[] will still try to look for 'Frame'.
To Reproduce
Add $parents["typeName"] references inside page view.
Execute 'tns run --env.uglify'
Expected behavior
Class and Function names should be kept as is and $parents[] references should work properly.
Additional context
In the past, I submitted a bug report regarding this issue in NS repository but I didn't know what the cause of it is.
NativeScript/NativeScript#8541
If the following properties are set in TerserPlugin, inside 'terserOptions' and 'compress' objects, problem will be solved.
keep_classnames: true,
keep_fnames: true