NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

[BUG] TerserPlugin breaks $parents["typeName"] functionality #1142

Open CatchABus opened 4 years ago

CatchABus commented 4 years ago

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):

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. https://github.com/NativeScript/NativeScript/issues/8541

If the following properties are set in TerserPlugin, inside 'terserOptions' and 'compress' objects, problem will be solved.

keep_classnames: true,
keep_fnames: true