diff --git a/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts deleted file mode 100644 index 70d9d9525f80..000000000000 --- a/packages/universal-cli/blueprints/universal/files/__path__/app/app.browser.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file and `main.node.ts` are identical, at the moment(!) - * By splitting these, you're able to create logic, imports, etc that are "Platform" specific. - * If you want your code to be completely Universal and don't need that - * You can also just have 1 file, that is imported into both - * client.ts and server.ts - */ - -import { NgModule } from '@angular/core'; -import { UniversalModule } from 'angular2-universal'; -import { FormsModule } from '@angular/forms'; -import { AppComponent } from './index'; -// import { RouterModule } from '@angular/router'; -// import { appRoutes } from './app/app.routing'; - -/** - * Top-level NgModule "container" - */ -@NgModule({ - /** Root App Component */ - bootstrap: [ AppComponent ], - /** Our Components */ - declarations: [ AppComponent ], - imports: [ - /** - * NOTE: Needs to be your first import (!) - * BrowserModule, HttpModule, and JsonpModule are included - */ - UniversalModule, - FormsModule - /** - * using routes - */ - // RouterModule.forRoot(appRoutes) - ] -}) -export class AppModule { - -} diff --git a/packages/universal-cli/blueprints/universal/files/__path__/app/app.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.module.ts new file mode 100644 index 000000000000..6963a550b575 --- /dev/null +++ b/packages/universal-cli/blueprints/universal/files/__path__/app/app.module.ts @@ -0,0 +1,73 @@ +/** + * This file and `main.browser.ts` are identical, at the moment(!) + * By modifying the uniqueTo* definitions, you're able to create logic, + * imports, etc that are "Platform" specific. + * + * If you want your code to be completely Universal and don't need that + * You can also modiy just the commonModule definition + * + */ + +import { NgModule } from '@angular/core'; +import { UniversalModule } from 'angular2-universal'; +import { FormsModule } from '@angular/forms'; +import { AppComponent } from './index'; +// import { RouterModule } from '@angular/router'; +// import { appRoutes } from './app/app.routing'; + +const commonModule = { + /** Root App Component */ + bootstrap: [AppComponent], + /** Our Components */ + declarations: [AppComponent], + imports: [ + /** + * NOTE: Needs to be your first import (!) + * NodeModule, NodeHttpModule, NodeJsonpModule are included + */ + UniversalModule, + FormsModule, + /** + * using routes + */ + // RouterModule.forRoot(appRoutes) + ], + providers: [] +}; + +const uniqueToClientModule = { + bootstrap: [], + declarations: [], + imports: [], + providers: [] +}; + +const uniqueToServerModule = { + bootstrap: [], + declarations: [], + imports: [], + providers: [] +}; + +/** + * Top-level NgModule "container" + */ +@NgModule({ + bootstrap: [...commonModule.bootstrap, uniqueToClientModule.bootstrap], + declarations: [...commonModule.declarations, uniqueToClientModule.declarations], + imports: [...commonModule.imports, uniqueToClientModule.imports], + providers: [...commonModule.providers, uniqueToClientModule.providers] +}) +export class AppModule { + +} + +@NgModule({ + bootstrap: [...commonModule.bootstrap, uniqueToServerModule.bootstrap], + declarations: [...commonModule.declarations, uniqueToServerModule.declarations], + imports: [...commonModule.imports, uniqueToServerModule.imports], + providers: [...commonModule.providers, uniqueToServerModule.providers] +}) +export class AppNodeModule { + +} diff --git a/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts b/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts deleted file mode 100644 index 89298579c259..000000000000 --- a/packages/universal-cli/blueprints/universal/files/__path__/app/app.node.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file and `main.browser.ts` are identical, at the moment(!) - * By splitting these, you're able to create logic, imports, etc that are "Platform" specific. - * If you want your code to be completely Universal and don't need that - * You can also just have 1 file, that is imported into both - * client.ts and server.ts - */ - -import { NgModule } from '@angular/core'; -import { UniversalModule } from 'angular2-universal'; -import { FormsModule } from '@angular/forms'; -import { AppComponent } from './index'; -// import { RouterModule } from '@angular/router'; -// import { appRoutes } from './app/app.routing'; - -/** - * Top-level NgModule "container" - */ -@NgModule({ - /** Root App Component */ - bootstrap: [ AppComponent ], - /** Our Components */ - declarations: [ AppComponent ], - imports: [ - /** - * NOTE: Needs to be your first import (!) - * NodeModule, NodeHttpModule, NodeJsonpModule are included - */ - UniversalModule, - FormsModule - /** - * using routes - */ - // RouterModule.forRoot(appRoutes) - ] -}) -export class AppModule { - -} diff --git a/packages/universal-cli/blueprints/universal/files/__path__/client.ts b/packages/universal-cli/blueprints/universal/files/__path__/client.ts index 6e1dff147e6b..1fb2ca052273 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/client.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/client.ts @@ -6,7 +6,7 @@ import './__2.1.1.workaround.ts'; // temporary until 2.1.1 things are patched in import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; import { platformUniversalDynamic } from 'angular2-universal'; -import { AppModule } from './app/app.browser.module'; +import { AppModule } from './app/app.module'; /** * enable prod mode for production environments diff --git a/packages/universal-cli/blueprints/universal/files/__path__/server.ts b/packages/universal-cli/blueprints/universal/files/__path__/server.ts index d9cd7b7067c3..52ad8cd458ee 100644 --- a/packages/universal-cli/blueprints/universal/files/__path__/server.ts +++ b/packages/universal-cli/blueprints/universal/files/__path__/server.ts @@ -8,7 +8,7 @@ import * as express from 'express'; import * as compression from 'compression'; import { createEngine } from 'angular2-express-engine'; import { enableProdMode } from '@angular/core'; -import { AppModule } from './app/app.node.module'; +import { AppNodeModule } from './app/app.module'; import { environment } from './environments/environment'; import { routes } from './server.routes'; @@ -56,7 +56,7 @@ function ngApp(req: any, res: any) { res.render('index', { req, res, - ngModule: AppModule, + ngModule: AppNodeModule, preboot: false, baseUrl: '/', requestUrl: req.originalUrl,