JS minification kills key/value map

Hi,
I have some key value config maps which I provide like

export const CFG = {someKey: 'someValue', someOther: {someMore:'value'}};

But it seems after optimization the keys of this map are replaced by single letters while references to those are not always replaced. Can I somehow ignore all files within one folder from optimization or how can I do this right?

ionic info

cli packages: (C:\Users\xx\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.2.3 browser 4.1.0
Ionic Framework    : ionic-angular 3.5.3

System:

Android SDK Tools : 25.2.5
Node              : v7.9.0
npm               : 5.4.0
OS                : Windows 10

Are you attempting to make this a global constant?

If so, my first instinct is just to tell you to use a provider.

This issue is quite common, most of the js file minification / compression tools are way too aggressive and scrap files (for example all scripts based upon Uglify destroys most sensitive Js scripts like Prototype). You can try some of the few tools that are well coded, I used a local script to setup lately in node.js, but I don’t remember the URL sorry.

A few ideas in mind, what you’ll be looking for is not ultra compression/minification, rather code respect and not too much line breaking:


http://yui.github.io/yuicompressor/
https://developers.google.com/closure/compiler/docs/api-tutorial3

Happy coding,

I completely disagree. If my code can’t be minimized, it’s my fault.

See it as kind of configuration file for different modules and their providers. I Can’t use json since I already build some small object structures in there. Even if I would provide this from a service it would get minified, right? I need this config as it is to pass it into other providers… So, the objects keys must not be minified here…

Sorry, forget it… It seems like its either not replaced or everwhere replaced correctly. The issue I had was something else (an invisible exception which prevent some initialization code to properly execute). I guess Chrome is not 100% correct when doing remote debugging with source maps, since it seems sometimes it showed me “my” names of the keys, and sometimes showed me single letters. I guess when showing my names it came from the source map while the other one showed the value currently used by device internally. So I was wrong when I thought the minification would break something. It works well :slight_smile: