title: Type X is part of the declarations of 2 modules (Angular 2 RC5)
body: <p>I'm toying around with Angular 2 RC5 and have run into the following problem:</p>
  
  <blockquote>
    <p>"Error: Type WelcomeComponent is part of the declarations of 2 modules: WelcomeModule and AppModule!</p>
  </blockquote>
  
  <p><strong>app.module.ts</strong></p>
  
  <pre><code>import { NgModule }      from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  import { Routes, RouterModule }  from '@angular/router';
  import { WelcomeModule } from './welcome/welcome.module';
  import { AppComponent }  from './app.component';
  import { 
      routing, 
      appRoutingProviders 
  } from './app.routing';
  
  @NgModule({
    imports:      [ 
    BrowserModule, 
    RouterModule, 
    WelcomeModule,
    routing
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ],
    providers:    [ appRoutingProviders ]
  })
  export class AppModule { }
  </code></pre>
  
  <p><strong>app.routing.ts</strong></p>
  
  <pre><code>import { 
      Routes,
      RouterModule 
  } from '@angular/router';
  
  import { welcomeRoutes } from './welcome/welcome.routing';
  
  const appRoutes: Routes = [
       ...welcomeRoutes
  ];
  
  export const appRoutingProviders: any[] = [];
  export const routing = RouterModule.forRoot(appRoutes);
  </code></pre>
  
  <p><strong>welcome.module.ts</strong></p>
  
  <pre><code>import { NgModule } from '@angular/core';
  
  import { WelcomeComponent } from './welcome.component';
  
  @NgModule({
      declarations: [ WelcomeComponent ]
  })
  export class WelcomeModule { }
  </code></pre>
  
  <p><strong>welcome.routing.ts</strong></p>
  
  <pre><code>import { 
      Routes,
      RouterModule 
  } from '@angular/router';
  
  import { WelcomeComponent } from './welcome.component';
  
  export const welcomeRoutes: Routes = [
      { path: 'welcome', component: WelcomeComponent }
  ];
  
  export const welcomeRoutingProviders: any[] = [];
  export const welcomeRouting = RouterModule.forChild(welcomeRoutes);
  </code></pre>
  
  <p>I can see what Angular is complaining about, <code>welcomeRoutes</code> requires <code>WelcomeComponent</code> from <code>WelcomeModule</code> to be defined, <code>appRoutes</code> references <code>welcomeRoutes</code> and <code>routing</code> is imported in <code>AppModule</code> which has <code>WelcomeModule</code>imported, but how am I supposed to build a routes graph spanning multiple modules then?</p>
  
  <p>The only solution that I can see is to remove </p>
  
  <pre><code>import { WelcomeModule } from './welcome/welcome.module'
  </code></pre>
  
  <p>but that kind of would defy the whole purpose of having modules in the first place, wouldn't it?</p>