diff --git a/src/commands/serve.ts b/src/commands/serve.ts index f43118c..5524ed7 100644 --- a/src/commands/serve.ts +++ b/src/commands/serve.ts @@ -15,17 +15,13 @@ command( return args }, args => { - serve(args.prod, args.aot) + serve(args.prod) } ) .option('prod', { default: false, description: 'Run with optimizations enabled' }) - .option('aot', { - default: false, - description: 'Pass through AOT Compiler' - }) .option('sw', { default: false, description: 'Enable service-worker' @@ -39,7 +35,7 @@ function logServeCommandStart() { logInfo('Launching Serve Command') } -function serve(isProdBuild = false, isAotBuild = false) { +function serve(isProdBuild = false) { readConfig_() .pipe( tap(logServeCommandStart), @@ -47,6 +43,7 @@ function serve(isProdBuild = false, isAotBuild = false) { ) .subscribe(config => { const cache = !isProdBuild + const isAotBuild = isProdBuild const log = config.fusebox.verbose || false const homeDir = resolve('.') const serverOutput = resolve(config.fusebox.server.outputDir) diff --git a/src/generators/angular-core.gen.ts b/src/generators/angular-core.gen.ts index 8dcdd20..d2eb01b 100644 --- a/src/generators/angular-core.gen.ts +++ b/src/generators/angular-core.gen.ts @@ -8,7 +8,11 @@ import { writeFile_, mkDirAndContinueIfExists_ } from '../utilities/rx-fs' import { forkJoin } from 'rxjs' import { resolve } from 'path' import { flatMap } from 'rxjs/operators' -import { browserModuleTemplate } from '../templates/core/browser' +import { + browserModuleTemplate, + browserAotEntryTemplate, + browserJitEntryTemplate +} from '../templates/core/browser' import { serverTemplate, serverModuleTemplate, @@ -62,7 +66,15 @@ export function generateCoreAngularBrowser(projectDir: string) { flatMap(() => mkDirAndContinueIfExists_(baseDir)), flatMap(() => forkJoin([ - writeFile_(`${baseDir}/app.browser.module.ts`, browserModuleTemplate) + writeFile_(`${baseDir}/app.browser.module.ts`, browserModuleTemplate), + writeFile_( + `${baseDir}/app.browser.entry.jit.ts`, + browserJitEntryTemplate + ), + writeFile_( + `${baseDir}/app.browser.entry.aot.ts`, + browserAotEntryTemplate + ) ]) ) ) diff --git a/src/templates/core/browser/app.browser.entry.aot.ts.txt b/src/templates/core/browser/app.browser.entry.aot.ts.txt new file mode 100644 index 0000000..befa0ab --- /dev/null +++ b/src/templates/core/browser/app.browser.entry.aot.ts.txt @@ -0,0 +1,4 @@ +import { platformBrowser } from '@angular/platform-browser' +import { AppBrowserModuleNgFactory } from './app.browser.module.ngfactory' + +platformBrowser().bootstrapModuleFactory(AppBrowserModuleNgFactory) diff --git a/src/templates/core/browser/app.browser.entry.jit.ts.txt b/src/templates/core/browser/app.browser.entry.jit.ts.txt new file mode 100644 index 0000000..08f863b --- /dev/null +++ b/src/templates/core/browser/app.browser.entry.jit.ts.txt @@ -0,0 +1,4 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' +import { AppBrowserModule } from './app.browser.module' + +platformBrowserDynamic().bootstrapModule(AppBrowserModule) diff --git a/src/templates/core/browser/app.browser.module.ts.txt b/src/templates/core/browser/app.browser.module.ts.txt index 1d86347..fc953db 100644 --- a/src/templates/core/browser/app.browser.module.ts.txt +++ b/src/templates/core/browser/app.browser.module.ts.txt @@ -1,6 +1,5 @@ import { AppModule } from '../app/app.module' import { NgModule } from '@angular/core' -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' import { BrowserTransferStateModule, BrowserModule } from '@angular/platform-browser' import { AppComponent } from '../app/app.component' @@ -14,4 +13,3 @@ import { AppComponent } from '../app/app.component' }) export class AppBrowserModule { } -platformBrowserDynamic().bootstrapModule(AppBrowserModule) diff --git a/src/templates/core/browser/index.ts b/src/templates/core/browser/index.ts index b8ca957..0b1d514 100644 --- a/src/templates/core/browser/index.ts +++ b/src/templates/core/browser/index.ts @@ -1,5 +1,9 @@ import * as browserModuleTemplate from './app.browser.module.ts.txt' +import * as browserJitEntryTemplate from './app.browser.entry.jit.ts.txt' +import * as browserAotEntryTemplate from './app.browser.entry.aot.ts.txt' export { - browserModuleTemplate -} \ No newline at end of file + browserModuleTemplate, + browserJitEntryTemplate, + browserAotEntryTemplate +} diff --git a/src/templates/declarations.ts.txt b/src/templates/declarations.ts.txt index 0c5b740..9572bc1 100644 --- a/src/templates/declarations.ts.txt +++ b/src/templates/declarations.ts.txt @@ -1,4 +1,9 @@ declare module "*.json" { const value: any; export default value; -} \ No newline at end of file +} + +declare module "*./app.browser.module.ngfactory" { + const value: any; + export { AppBrowserModuleNgFactory }; +} diff --git a/src/templates/fusebox.ts b/src/templates/fusebox.ts index 984360d..5acd0fa 100644 --- a/src/templates/fusebox.ts +++ b/src/templates/fusebox.ts @@ -2,8 +2,8 @@ export const FUSEBOX_DEFAULTS = { verbose: false, browser: { outputDir: '.dist/public/js', - browserModule: 'src/browser/app.browser.jit.entry.ts', - aotBrowserModule: '.aot/src/browser/app.browser.aot.entry.js', + browserModule: 'src/browser/app.browser.entry.jit.ts', + aotBrowserModule: '.aot/src/browser/app.browser.entry.aot.js', prod: { uglify: true, treeshake: true @@ -11,6 +11,6 @@ export const FUSEBOX_DEFAULTS = { }, server: { outputDir: '.dist', - serverModule: 'server/server.ts' + serverModule: 'src/server/server.ts' } } diff --git a/src/templates/tsconfig.aot.json.txt b/src/templates/tsconfig.aot.json.txt index dea338b..f32e763 100644 --- a/src/templates/tsconfig.aot.json.txt +++ b/src/templates/tsconfig.aot.json.txt @@ -24,7 +24,7 @@ "src" ], "exclude": [ - "src/browser/app.browser.jit.entry.ts" + "src/browser/app.browser.entry.jit.ts" ], "angularCompilerOptions": { "genDir": ".aot",