-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for AoT compilation #1732
Comments
@elvirdolic i believe AoT compilation is a perquisite to declaring an 1.0 release. So while it is not there right now it will be there as we approach an official release of angular2 |
We definitely plan on having it, but I don't have a timeline to give. It's a big thing on our radar though. |
@elvirdolic just an fyi I have gotten an angular-cli build working with AOT compilation so it is possible to roll it yourself for now if you want to play around with it. |
@deebloo please provide us the steps to make AOT on cli webpack |
@deebloo it would be very useful to me too, and I am sure also to other people. Thanks! |
Any luck with AOT? |
Yeah also interested. |
This repo provides some hacks. Check it out https://github.com/brandonroberts/router-cli-aot/blob/master/README.md |
@elvirdolic this is not webpack |
I've just played with angular-cli all day and I must say that it is AWESOME 💯 ! But I miss the AoT compilation thu. Is there any progress? When can I expect a working prototype? Is it a matter of days or rather weeks? Thanks for your answer. |
Yes in the latest version you can try ng build --prod --aot. But its not officially described in the docs. |
I have a question... what is actually happen, when I add --aot flag? In angular.io docs, there is a tutorial for AoT compilation that includes 2 changes, one in tsconfig (for ngc) and second in main.ts (replace platform-browser-dynamic with platform-browser). If I do these changes, build with --aot stop working. If I keep them without any change, --aot works but I think that it still keeps platform-browser-dynamic in the bundle and loads JiT... isn't it? edit: and if changes in tsconfig.json and main.ts are required, how can I change config for dev and production to use e.g. main.ts or main.aot.ts respectively? |
I think you don't have to change anything. This is the magic of angular-cli you don't have to worry about that. Use the flag and the rest will be done in the background. Aot is still in WIP. Lets wait for a official relase statement maybe there is some config change required. |
i am sorry but what is AoT? |
@elvirdolic: correct, there is NO config change needed for AoT, and we're making sure that it's backward compatible with your project. Some extreme cases might confuse our tooling so it will error out, but this should only happen if do strange things (such as declaring your classes but exporting them by another name, for example). If you follow the blueprints, and even if you do some code yourself, it should work just fine. @k1ng440: AoT is ahead-of-time compilation. Look up "Angular 2 AoT" on youtube to see what's it about. |
@hansl is this feature usuable? |
@jordic |
@castamir not works aot with lazy routes |
Ok @castamir. Not sure if this is the place to ask this, but when I launch ng serve --aot I've got this error:
Are there any step I missed, or there is something in my codebase not properly defined/structured? May someone give and advice? |
Hello i encountered an issue:
the window is from lib.d.ts as far as i can tell, this is my tsconfig
this is the relevant part from my .ts file
if i only change the Window-type to any inside the constructor parameters it works
in my module.ts file i have following
Any ideas why Window cannot be statically analyzed? |
@sebastian-heinz what does your Window type look like? this might help |
@castamir thank you for the headsup, i checked the article, but i still can not wrap my head around how to import the Window-Type from lib.d.ts properly. if i follow the decleration of Window i get to lib.d.ts
so i tried to import it: (Before i did not had any import of Window, and the IDE would resolve it to the lib.d.ts file)
but this wont work as its not a module?
Im not sure how to do this, or if its necessary since it work with the any-Type |
As an update, |
This pr #2470 added support for tsconfig |
|
@monfa-red allow me to give some non-contributor thoughts about your answer.
|
OK. I tried this in beta.21. Still having issues with AoT. ng build --aot
ng build -prod --aot
ng serve --aotThis one only hangs with the following output
RemarksCLI VersionThis is tested with angular-cli beta.21 on macOS Sierra with Node v6.9.1 and NPM 4.0.2. Sample DetailsThis is the following relevant import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {SimpleRouteComponent} from './simple-route/simple-route.component';
import {BundledModule} from './bundled/bundled.module';
export function loadBundledModule() { return BundledModule; }
export const routes: Routes = [
{
path: '',
pathMatch: 'full',
component: SimpleRouteComponent
},
{
path: 'bundled',
loadChildren: loadBundledModule
},
{
path: 'lazy',
loadChildren: './lazy/lazy.module#LazyModule'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
export class AppRoutingModule { } The AoT commands above only work when I comment the 2nd and 3rd routes, changing the definition of export const routes: Routes = [
{
path: '',
pathMatch: 'full',
component: SimpleRouteComponent
},
// {
// path: 'bundled',
// loadChildren: loadBundledModule
// },
// {
// path: 'lazy',
// loadChildren: './lazy/lazy.module#LazyModule'
// }
]; Note that this means that even loading other modules directly (not with lazy loading) is also not working with AoT, not just lazy loading. Update Coping @hansl because he was the last one I knew of working on this. |
@Meligy I'm having exactly the same issue here |
This is the same issue I am having and trying to work through. I am using beta 22-1 and the latest beta 23 @master but I cannot get lazy loading to work at all. I have been at this for hours... It does work in beta 21. |
Hmm.. I am using beta.24 and after running |
FYI, I just upgraded to angular-cli beta24 and Angular 2.4.0 on my test project https://github.com/ryzy/play-ng2-github/ and AoT seems to work perfectly fine. It loads in ~.5s compared to ~1.5s without AoT. |
Closing this as obsolete. We've been supporting AOT for a while; bugs should have their own issues in GitHub from now on. |
@ryzy we had people request that we don't remove decorators. It is using AOT and the Angular compiler isn't included, but the decorators are still there. Working towards the real solution. |
I often use AOT in my angular 2 app. But meanwhile I am facing the issue that as it gives the "Property 'staff_name' does not exist on type 'StaffRentListComponent' in my previous files history. Means it shows deleted code in ngfactory.ts (in AOT bundle folder) file and there is no code in my actual .ts file. Please let me know that how can I resolve this issue. |
@ryzy I tried downloading your github project for verifying AoT speed test. But somehow npm install doesnt work because of dependencies. Can you please let me know how do we verify Aot speed test? Do I need to replace platform-browser-dynamic with platform-browser in main.ts file? |
It seems that with AOT compilation, especially with Angular CLI, there is no window at the build time. I ended up with an option to implement a separate Window Service, which returns a window instance, to operate with. Reference: http://stackoverflow.com/questions/34177221/angular2-how-to-inject-window-into-an-angular2-service PS: Refering to the examples in the SO question above, you can directly implement the import {Injectable} from "@angular/core";
@Injectable()
export class WindowService {
static get window(): any {
return window;
}
} |
Is the bs-config.aot.ts file now deprecated / not required for aot to work? It's not mentioned in the documentation, but other websites make a reference to it. Nor is it included in the angular-cli. @Rolice I know that the bs-config.aot.ts file (if is does get used) has an |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Are there any plans to support AoT compilation in angular-cli?
The text was updated successfully, but these errors were encountered: