title: AngularCLI Production Build Breaks Dictionary Injection
body: <p>We have an Angular application which we followed the advice in this turorial:</p>
  
  <p><a href="https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-1" rel="nofollow noreferrer">https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-1</a></p>
  
  <p>In order to have a simple framework for replacing values based on which deployment it is.  This all works fine but when we do an angular cli --prod build the translations object is empty.</p>
  
  <p>The basic setup is as per the attached tutorial but basically we have a const as follows:</p>
  
  <pre><code>export const COLL1_TRANSLATIONS = {
  "Key1": "Value1",
  "Key2": "Value2",
  "Key3": "Value3",
  };
  
  // translation token
  export const TRANSLATIONS = new InjectionToken('translations');
  
  // all translations
  const dictionary = {};
  dictionary["COLL1_NAME"] = COLL1_TRANSLATIONS;
  
  // providers
  export const TRANSLATION_PROVIDERS = [
      { provide: TRANSLATIONS, useValue: dictionary },
  ];
  
  @Injectable()
  export class TranslateService {
    public get currentLang() {
      return this._currentLang || this._defaultLang;
    }
  
    // inject our translations
    constructor( @Inject(TRANSLATIONS) private _translations: any) {
      console.log(_translations);
    }
  }
  </code></pre>
  
  <p>When we run the build without --prod everything works fine and the console.log has the populated dictionary, when we run with --prod on the cli build the dictionary is empty.</p>
  
  <p>This is several code snippets from several files to give the basic idea but is almost identical to the tutorial link above, as mentioned works absolutely as expected when we don't do a --prod build so the question is why is --prod breaking the injection of the dictionary?</p>
  
  <p>UPDATE:
  If I add --aot=false to the prod build then everything works fine again, is there a way to make this work with aot?</p>