2

プロダクション リリース用にコンパイルするときの Angular2 AOT の問題 - アプリ モジュールの問題

systemjsでangular2、typescript、html5を使用しています

これは私が使用している angular2 シード アプリです: https://github.com/mgechev/angular-seed

この git bash コマンドを実行すると、npm run serve.prod.exp で AOT のビルド パッケージが作成されます。その後、git bash でエラーが発生します。

これは私が得るエラーAOTビルドエラーです:

ここに画像の説明を入力

これは私の app.module です:

import { NgModule } from '@angular/core';
import { routes } from './app.routes';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { FormsModule} from '@angular/forms';
import { APP_BASE_HREF, CommonModule, Location } from '@angular/common';
import { RouterModule } from '@angular/router';
import { MetadataModule } from 'ng2-metadata';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { CanActivateViaAuthGuard } from './guard.module';

//Pages
import { HomeModule } from './components/home/home.module';
import { ContactModule } from './components/contact/contact.module';
import { ForgotPasswordModule } from './components/forgotPassword/forgotPassword.module';
import { LoginModule } from './components/login/login.module';
import { RegisterModule } from './components/register/register.module';
import { NewJobsModule } from './components/newJobs/newJobs.module';
import { NewJobModule } from './components/newJob/newJob.module';
import { BlogModule } from './components/blog/blog.module';
import { BlogArticleModule } from './components/blogArticle/blogArticle.module';
import { SocialRegisterModule } from './components/socialRegister/socialRegister.module';
import { AdminModule } from './components/admin/admin.module';
import { ApplicationsModule } from './components/applications/applications.module';
import { ChangeEmailModule } from './components/changeEmail/changeEmail.module';
import { ChangePasswordModule } from './components/changePassword/changePassword.module';
import { CompanyModule } from './components/company/company.module';
import { CreateJobModule } from './components/createJob/createJob.module';
import { DashboardModule } from './components/dashboard/dashboard.module';
import { HelpModule } from './components/help/help.module';
import { InviteModule } from './components/invite/invite.module';
import { JobModule } from './components/job/jobs.module';
import { MessagesModule } from './components/messages/messages.module';
import { MessengerModule } from './components/messenger/messenger.module';
import { ProfileModule} from './components/profile/profile.module';
import { SearchJobsModule } from './components/searchJobs/searchJobs.module';
import { SearchUsersModule } from './components/searchUsers/searchUsers.module';
import { UserApplicationsModule } from './components/userApplications/userApplications.module';
import { SiteMapModule } from './components/sitemap/sitemap.module';
import { SplashModule } from './components/splash/splash.module';
import { PageNotFoundModule } from './components/pageNotFound/pageNotFound.module';
import { TermsModule } from './components/terms/terms.module';
import { PrivacyModule } from './components/privacy/privacy.module';
import { CompetitionModule } from './components/competition/competition.module';
import { FaqModule } from './components/faq/faq.module';
import { AboutModule } from './components/about/about.module';
import { DBSModule } from './components/dbs/dbs.module';
import { Module400 } from './components/400/400.module';
import { Module404 } from './components/404/404.module';
import { Module500 } from './components/500/500.module';

//Services and modules
import { AuthService } from './services/authService/authService';
import { MessageService } from './services/messageService/messageService';
import { UserService } from './services/userService/userService';
import { UserProfile } from './models/profile/profile';
import { JobService } from './services/jobService/jobService';
import { Job } from './models/job/job';
import { Environment } from './models/environment/environment';

//Shared
import { HeaderComponent } from './components/shared/header/header.module';
import { HeaderCompanyComponent } from './components/shared/headerCompany/headerCompany.module';
import { HeaderUserComponent } from './components/shared/headerUser/headerUser.module';
import { SideMenuUserComponent } from './components/shared/sideMenuUser/sideMenuUser.module';
import { SideMenuCompanyComponent } from './components/shared/sideMenuCompany/sideMenuCompany.module';
import { FooterModule } from './components/shared/footer/footer.module';

@NgModule({
  imports: [BrowserModule, FormsModule, RouterModule, CommonModule, HttpModule, FooterModule, MetadataModule.forRoot(), RouterModule.forRoot(routes), 
  HomeModule, 
  ContactModule, 
  ForgotPasswordModule, 
  LoginModule,
  RegisterModule,
  NewJobsModule,
  NewJobModule,
  BlogModule,
  BlogArticleModule,
  SiteMapModule,
  SocialRegisterModule,
  ProfileModule,
  SplashModule,
  CompanyModule,
  ChangeEmailModule,
  ChangePasswordModule,
  DashboardModule,
  HelpModule,
  InviteModule,
  MessagesModule,
  MessengerModule,
  UserApplicationsModule,
  SearchUsersModule,
  ApplicationsModule,
  JobModule,
  CreateJobModule,
  SearchJobsModule,
  TermsModule,
  PrivacyModule,
  FaqModule,
  Module400,
  Module500,
  Module404,
  DBSModule,
  CompetitionModule,
  PageNotFoundModule,
  AboutModule,
  AdminModule
  ],
  declarations: [AppComponent, HeaderComponent, HeaderUserComponent, SideMenuUserComponent, SideMenuCompanyComponent, HeaderCompanyComponent],
  providers: [{
    provide: APP_BASE_HREF,
    useValue: '<%= APP_BASE %>'},
    AuthService,
    UserService,
    UserProfile,
    JobService,
    Job,
    MessageService,
    Environment,
    CanActivateViaAuthGuard
  ],
  bootstrap: [AppComponent]
})

export class AppModule { }

*私のアプリからコードを表示する必要がある場合はお知らせください。

このアプリをビルドして、AOT で実行し、アプリの初回読み込み時の読み込み時間を短縮したいだけです。現在、ロード時間は 4 秒です。

アプリのルート:

import { Routes } from '@angular/router';

import { HomeRoutes } from './components/home/index';
import { ContactRoutes } from './components/contact/index';
import { ForgotPasswordRoutes } from './components/forgotPassword/index';
import { LoginRoutes } from './components/login/index';
import { RegisterRoutes } from './components/register/index';
import { NewJobsRoutes } from './components/newJobs/index';
import { NewJobRoutes } from './components/newJob/index';
import { BlogRoutes } from './components/blog/index';
import { BlogArticleRoutes } from './components/blogArticle/index';
import { SocialRegisterRoutes } from './components/socialRegister/index';
import { AdminRoutes } from './components/admin/index';
import { ApplicationsRoutes } from './components/applications/index';
import { ChangeEmailRoutes } from './components/changeEmail/index';
import { ChangePasswordRoutes } from './components/changePassword/index';
import { CompanyRoutes } from './components/company/index';
import { CreateJobRoutes } from './components/createJob/index';
import { DashboardRoutes } from './components/dashboard/index';
import { HelpRoutes } from './components/help/index';
import { InviteRoutes } from './components/invite/index';
import { JobRoutes } from './components/job/index';
import { MessagesRoutes } from './components/messages/index';
import { MessengerRoutes } from './components/messenger/index';
import { ProfileRoutes } from './components/profile/index';
import { SearchJobsRoutes } from './components/searchJobs/index';
import { SearchUsersRoutes } from './components/searchUsers/index';
import { UserApplicationsRoutes } from './components/userApplications/index';
import { SiteMapRoutes } from './components/sitemap/index';
import { TermsRoutes } from './components/terms/index';
import { FAQRoutes } from './components/faq/index';
import { PrivacyRoutes } from './components/privacy/index';
import { CompetitionRoutes } from './components/competition/index';
import { PageNotFoundRoutes } from './components/pageNotFound/index';
import { AboutRoutes } from './components/about/index';
import { Routes400 } from './components/400/index';
import { Routes404 } from './components/404/index';
import { Routes500 } from './components/500/index';
import { DBSRoutes } from './components/dbs/index';

export const routes: Routes = [
...HomeRoutes, 
...ContactRoutes,
...ForgotPasswordRoutes,
...LoginRoutes,
...RegisterRoutes,
...NewJobsRoutes,
...NewJobRoutes,
...BlogRoutes,
...BlogArticleRoutes,
...SiteMapRoutes,
...SocialRegisterRoutes,
...ProfileRoutes,
...CompanyRoutes,
...ChangeEmailRoutes,
...ChangePasswordRoutes,
...DashboardRoutes,
...HelpRoutes,
...InviteRoutes,
...MessagesRoutes,
...MessengerRoutes,
...UserApplicationsRoutes,
...SearchUsersRoutes,
...ApplicationsRoutes,
...JobRoutes,
...CreateJobRoutes,
...SearchJobsRoutes,
...AdminRoutes,
...TermsRoutes,
...PrivacyRoutes,
...FAQRoutes,
...CompetitionRoutes,
...Routes400,
...Routes404,
...Routes500,
...DBSRoutes,
...AboutRoutes,
...PageNotFoundRoutes
];

これは、ブートストラップを含むメイン ファイルです。

import { enableProdMode } from '@angular/core';
// The browser platform with a compiler
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
// The app module
import { AppModule } from './app.module';

if (String('<%= BUILD_TYPE %>') === 'prod') { enableProdMode(); }

platformBrowserDynamic().bootstrapModule(AppModule/*, options*/);
4

0 に答える 0