title: AOT compiler generates wrong import
body: <p>I have a multi-app angular-cli project with some code base sharing. </p>
  
  <p>Basically, the structure looks like following:</p>
  
  <ul>
  <li><strong>src</strong> - main application
  
  <ul>
  <li><strong>app.component</strong> - bootstrapped component</li>
  <li><strong>app.module</strong></li>
  <li><strong>shared</strong> - shared application parts
  
  <ul>
  <li><strong>demo.component</strong></li>
  <li><strong>shared.module</strong></li>
  </ul></li>
  </ul></li>
  <li><strong>extension</strong> - second application supposed to extend the main one
  
  <ul>
  <li><strong>extension-app.component</strong> - bootstrapped component</li>
  <li><strong>extension.module</strong></li>
  </ul></li>
  </ul>
  
  <p><code>SharedModule</code> (which declares and exports the <code>DemoComponent</code>) is imported by both <code>AppModule</code> and <code>ExtensionModule</code>. <code>DemoComponent</code> is then added to templates of both <code>AppComponent</code> and <code>ExtensionAppComponent</code>. </p>
  
  <p>Everything is working just fine when using JIT compiler (<code>ng serve</code>, <code>ng serve --app extension</code>), but AOT compiler fails saying:</p>
  
  <p><code>Can't resolve '../../../src/app/demo/demo.component.ngfactory'</code></p>
  
  <p>Looking into this generated file at <code>GENDIR/app/demo/demo.component.ngfactory</code> we get the following:</p>
  
  <pre><code>import * as i0 from './demo.component.css.shim.ngstyle';
  import * as i1 from '@angular/core';
  import * as i2 from './demo.component';
  </code></pre>
  
  <p>The last one import is the one that fails, because there is no 'demo.component' in the <code>GENDIR/app/demo</code> folder. Surprisingly the file imported as <code>i0</code> does exist and contains appropriate styles.</p>
  
  <p><em>UPDATE: looks like the problem is in <code>ngc</code>. It would neither work even if you add a <code>paths</code> alias in <code>tsconfig.json</code>. There are a couple of issues about it on github (<a href="https://github.com/angular/angular/issues/13487" rel="nofollow noreferrer">https://github.com/angular/angular/issues/13487</a>)</em></p>