Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何导入AppModuleNgFactory以引导aot构建_Angular_Angular Cli - Fatal编程技术网

Angular 如何导入AppModuleNgFactory以引导aot构建

Angular 如何导入AppModuleNgFactory以引导aot构建,angular,angular-cli,Angular,Angular Cli,我正在尝试设置一个使用angular cli创建的基本angular应用程序,以便使用aot进行编译。由于angular cli隐藏了tsconfig.json文件,我无法找到描述如何执行此操作的相关文档,因此很难弄清楚main.ts文件应该是什么样子才能引导应用程序。有人能帮我正确设置吗 我的ng版本是 angular-cli: 1.0.0-beta.25.5 │1

我正在尝试设置一个使用angular cli创建的基本angular应用程序,以便使用aot进行编译。由于angular cli隐藏了tsconfig.json文件,我无法找到描述如何执行此操作的相关文档,因此很难弄清楚main.ts文件应该是什么样子才能引导应用程序。有人能帮我正确设置吗

我的
ng版本

angular-cli: 1.0.0-beta.25.5                                                                  │127.0.0.1 - - [18/Jan/2017 12:09:31] "GET /main.bundle.map HTTP/1.1" 200     -
node: 7.4.0                                                                               │^C
os: linux x64                                                                             │Keyboard interrupt received, exiting.
@angular/common: 2.4.3                                                                    │joi ~/workspace/angular2/testing/dist $ cd ..
@angular/compiler: 2.4.3                                                                  │joi ~/workspace/angular2/testing $ cd dis
@angular/core: 2.4.3                                                                      │-bash: cd: dis: No such file or directory
@angular/forms: 2.4.3                                                                     │joi ~/workspace/angular2/testing $ cd dist
@angular/http: 2.4.3                                                                      │-bash: cd: dist: No such file or directory
@angular/platform-browser: 2.4.3                                                          │joi ~/workspace/angular2/testing $ cd dist
@angular/platform-browser-dynamic: 2.4.3                                                  │joi ~/workspace/angular2/testing/dist $ ls
@angular/router: 3.4.3                                                                    │assets       inline.bundle.js   main.bundle.map    vendor.bundle.js
@angular/compiler-cli: 2.4.3
package.json文件是:

{                                                                                                                                                                                
  "name": "testing",                                                                                                                                                             
  "version": "0.0.0",                                                                                                                                                            
  "license": "MIT",                                                                                                                                                              
  "angular-cli": {},                                                                                                                                                             
  "scripts": {                                                                                                                                                                   
    "ng": "ng",                                                                                                                                                                  
    "start": "ng serve",                                                                                                                                                         
    "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",                                
    "test": "ng test",                                                                                                                                                           
    "pree2e": "webdriver-manager update --standalone false --gecko false",                                                                                                       
    "e2e": "protractor"                                                                                                                                                          
  },                                                                                                                                                                             
  "private": true,                                                                                                                                                               
  "dependencies": {                                                                                                                                                              
    "@angular/common": "^2.3.1",                                                                                                                                                 
    "@angular/compiler": "^2.3.1",                                                                                                                                               
    "@angular/core": "^2.3.1",                                                                                                                                                   
    "@angular/forms": "^2.3.1",                                                                                                                                                  
    "@angular/http": "^2.3.1",                                                                                                                                                   
    "@angular/platform-browser": "^2.3.1",                                                                                                                                       
    "@angular/platform-browser-dynamic": "^2.3.1",                                                                                                                               
    "@angular/router": "^3.3.1",                                                                                                                                                 
    "core-js": "^2.4.1",                                                                                                                                                         
    "rxjs": "^5.0.1",                                                                                                                                                            
    "ts-helpers": "^1.1.1",                                                                                                                                                      
    "zone.js": "^0.7.2"                                                                                                                                                          
  },                                                                                                                                                                             
  "devDependencies": {                                                                                                                                                           
    "@angular/compiler-cli": "^2.3.1",                                                                                                                                           
    "@types/jasmine": "2.5.38",                                                                                                                                                  
    "@types/node": "^6.0.42",                                                                                                                                                    
    "angular-cli": "1.0.0-beta.25.5",                                                                                                                                            
    "codelyzer": "~2.0.0-beta.1",                                                                                                                                                
    "jasmine-core": "2.5.2",                                                                                                                                                     
    "jasmine-spec-reporter": "2.5.0",                                                                                                                                            
    "karma": "1.2.0",                                                                                                                                                            
    "karma-chrome-launcher": "^2.0.0",                                                                                                                                           
    "karma-cli": "^1.0.1",                                                                                                                                                       
    "karma-jasmine": "^1.0.2",                                                                                                                                                   
    "karma-remap-istanbul": "^0.2.1",                                                                                                                                            
    "protractor": "~4.0.13",                                                                                                                                                     
    "ts-node": "1.2.1",                                                                                                                                                          
    "tslint": "^4.3.0",                                                                                                                                                          
    "typescript": "~2.0.3"                                                                                                                                                       
  }                                                                                                                                                                              
}
main.ts文件当前如下所示:

import './polyfills.ts';                                                                                                                         
import { platformBrowser }    from '@angular/platform-browser';                                                                                                                      
import { AppModuleNgFactory } from './app/app.module.ngfactory';                                                                                                                     
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
创建您的项目:

ng new super-project
ng build
构建您的项目:

ng new super-project
ng build
使用AoT构建您的项目:

ng build --aot
庆祝


您不需要额外配置。

我正在寻找有关引导步骤的帮助。也就是说,我的问题是:main.ts中有什么内容可以引导应用程序CLI构建过程将在构建过程中看到的JIT引导代码替换为与AOT兼容的代码,因此如果您使用CLI及其构建过程,则无需执行任何操作。哦。那意味着我一直无缘无故地把我的had砸在桌子上?这很好,同时也有点烦人……我很困惑。使用aot编译的文件大小大于不使用aot编译的文件大小。你知道那里发生了什么吗?有了aot:dist/vendor.bundle.js:2.4M,dist/main.bundle.js:2.5M,dist/inline.bundle.js:8.0K,总数:490万,没有aot:dist/vendor.bundle.js:3.8M,dist/main.bundle.js:540K,dist/inline.bundle.js:8.0K,总数:430万