简体   繁体   English

Angular 2 AoT编译器:没有错误,但是肯定有问题

[英]Angular 2 AoT compiler: no error but something is definitely wrong

I've been banging my head at this for 3 days, trying to get Ahead-of-Time compilation of my Angular 2 rc.6 application to work. 我已经为此花了三天时间,试图让我的Angular 2 rc.6应用程序提前编译。

The application compiles and runs just fine using Just-in-Time compilation. 使用即时编译,应用程序可以编译并运行良好。

I have installed all dependencies, run ngc (the compiler), changed my main.ts to use platformBrowser() , and run ngc again. 我已经安装了所有依赖项,运行ngc (编译器),将main.ts更改为使用platformBrowser() ,然后再次运行ngc

There is no error in the console. 控制台中没有错误。 The .ngfactory.ts files are generated. .ngfactory.ts文件已生成。 The .js files also. .js文件也。 So far so good. 到现在为止还挺好。 Here is my structure (it's a mess but I'll address that if I can ever get this working) 这是我的结构(这是一团糟,但是如果可以的话,我会解决的)

目录结构

The app runs out of dist/ . 该应用程序用完dist/ Problem is, once I update systemjs.config.js and change map['app'] from dist to dist/dev and run the App, things go downhill fast. 问题是,一旦我更新了systemjs.config.js并将map['app']dist更改为dist/dev并运行该App,事情就会迅速下坡。

The first indication that something is really wrong is that whereas I expected the number of HTTP requests and the amount of data to be drastically reduced with AoT, the opposite happened. 第一个表明确实存在问题的迹象是,尽管我期望通过AoT可以大大减少HTTP请求的数量和数据量,但情况恰恰相反。 I now have 200 more requests at bootstrap! 我现在在引导程序上还有200个请求!

Secondly, even though there were no errors during compilation, the app will not run. 其次,即使在编译过程中没有错误,该应用程序也不会运行。 I get a 404 not found at the path: http://localhost/traceur . 我在以下路径404 not foundhttp://localhost/traceur What? 什么? Why is traceur involved? 为什么会涉及traceur isn't that used for in-browser transpilation? 是不是用于浏览器内移植? Where can I start looking for what's wrong? 我可以从哪里开始寻找问题所在?

Same,I followed the official guides with systemjs as my loader and using the UMD bundles. 同样,我按照官方指南使用systemjs作为加载程序并使用UMD捆绑包。 But that would not map correctly! 但这不会正确映射! So I re-configured my systemjs settings and am managing to get all the packages. 因此,我重新配置了systemjs设置,并设法获取了所有软件包。 But now traceur.js is the only missing package. 但是现在traceur.js是唯一缺少的软件包。 What is that about ?! 那是什么?!

Edit: So I mapped tracuer in systemjs, ,like so: 编辑:所以我在systemjs中映射了tracuer,就像这样:

'traceur': 'node_modules/traceur/src/traceur' 'traceur':'node_modules / traceur / src / traceur'

But... now nothing shows up on my page. 但是...现在我的页面上没有任何显示。 I believe my whole configuration with the packages is wrong to begin with though because why was my app requesting packages that weren't mapping correctly with the UMD bundles? 我认为从一开始我对软件包的整个配置是错误的,因为为什么我的应用程序请求的UMD包映射不正确?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM