title: TreeShakeable Providers in Angular 6 and Injector
body: <p>Angular 6 has introduced tree shakeable providers with the</p>
  
  <pre><code>@Inject({provideIn:'...'} 
  </code></pre>
  
  <p>syntax.</p>
  
  <p>In order to take advantage of the tree shaking aspect, does it make a difference whether I inject the service directly via the constructor or via an Injector?</p>
  
  <p>Example:</p>
  
  <p>Sevice:</p>
  
  <pre><code>@Inject({provideIn:'...'} 
  class MyService {}
  </code></pre>
  
  <p>Consumer1:</p>
  
  <pre><code>@Component()
  class MyComponent {
    constructor(s: MyService) {}
  }
  </code></pre>
  
  <p>Consumer2:</p>
  
  <pre><code>@Component()
  class MyComponent {
    constructor(@Inject(Injector) aInjector: Injector) {
       const s: MyService = aInjector.get(MyService);
    }
  }
  </code></pre>
  
  <p>In both cases MyService gets injected. I would expect that only in the first case the AOT compiler will be able to determine that the service is used via static analysis.</p>
  
  <p>What would be the effect if I used the second version? Would AOT detect the injection of Injector and then basically skip tree shaking for providers? Or is it smart enough to detect that MyService is fetched from the injector?</p>