-
Notifications
You must be signed in to change notification settings - Fork 12k
AOT seems to be enabled by default in beta.22 ? #3368
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
Comments
It looks like aot is enabled by default but I'cant even disable it. |
This has already been reported in #3354. |
These are the approximately gzipped production payload for my application: CLI beta 21/Angular 2.2.1 without AoT. main.bundle: 260kb, 0.chunk: 20kb... Basically with AoT, the main/vendor bundle reduced by about 20%, but all the other lazy/pre-loaded chunks increased, some by more than 100%. I compared the chunk's source and found that with AoT, the size increase seem to came from very many pre-compiled html js code, such as
where this._el_123 reference a renderer of an html tag. These "\n" code lines basically matches the closing HTML tag. Without AoT, these code would be replaced with plain HTML developers code up. Is this expected? Are there any work in progress to reduce the pre-compiled code size? Due to this increase, it may not be worth it in certain situation to turn on AoT. Not sure if this should be a CLI issue or an Angular2 framework issue. If so, please advise... |
I deleted a comment that was obviously against the code of conduct. |
@ritz078 we don't enable AoT by default, BUT we do generate lazy bundles. The code that analyze your project for lazy routes still uses static analysis to figure out your lazy routes. We had "faulty" code before that was working which we might revert too; it was dumber but in this case it would fix it. |
We changed the way we analyze lazy routes in the CLI; you now have to use statically analyzable code. This is more solid and also takes into account libraries that include routes and lazy routes. It also means the code needs to be AoT-compatible, even though you're not using AoT to compile it. The problem here seems to be that you either:
For point 1, you should not use function calls or non-const values in metadata. Metadata is supposed to be static and easily parseable. For point 2, we (the Angular Team) offer best practice guides for library developers to follow, in order to be AoT compatible. Libraries should follow those best practices. If you are (or know) the library author, this page explains how to be AoT compatible for a library: https://angular.io/docs/ts/latest/cookbook/aot-compiler.html |
It seems that the user experience(in my case ng serve stalling) is not ideal. Also, it seems that ng serve/build is ignore my tsconfig and using |
@hansl I'm not sure to understand, but if we use a non compatible AOT library, we won't be able to use angular-cli (except < beta 22) ? |
@maxime1992 seems so. + there are several new problems like using non-reexported types as return type of methods in exported class... @the-destro yeah.. with beta.22 i have 1000 errors like this regarding rxjs... and now i dont know how to fix those errors.. do you? IM so afraid, that this change - you need every library to be AOT compatible, will brake the neck of Angular 2..... |
Although it is momentarily inconvenient, I think it is a very positive development to see CLI requiring that code and libraries have the bits necessary to work with AOT. This should result in a better sense of urgency among application and library authors to become compatible with AOT. In the long run, I think this would be even better: for Angular itself to be modified a bit such that JIT imposes as close as possible to the same requirements as AOT. |
this will lead to the end of angular, because authors of 3rd party libraries wont invest their time to modify code and build it with ngc. |
@kylecordes I loved that I could use some older javascript libraries - for example jQuery jsTree, some color picker and so on.. and write simple wrapper for Angular 2. There are lost of non-angular libraries which are really great and up to this moment could be used (with some wrappers) with angular. Now if you cut them out, you end up with just bunch of Angular 2 libraries with very varying quality. I don't think it is a good idea. Right now no one is forcing me to use AOT, so I will avoid it as long as possible. But I'm also losing benefits of it - just because you decided to make this huge breaking change in beta.22. |
@klinki What I described would only affect Angular specific reusable libraries. It would not affect jQuery or any of zillions of other reusable chunks of code which don't have any Angular specific annotations / components / etc. in them. I'm not on the Angular team so I am not among the "you" who put in this change :-) but I think a couple of the messages here overstate the impact. The current situation is basically an accident of history, that the requirements for Angular code compatible with AOT are different than the requirements for angular code compatible with JIT. I suspect in a few more versions we will all have long forgotten that, the requirements will have been brought close enough that JIT is no big deal, routinely use, as the Angular team has had in mind for a long time. It's a big complicated thing, takes a while to accomplish the full vision. |
I agree with @kylecords. This won't affect non angular libs and now anything built with the cli will be AOT compliant. I do see that it is causing some pain but I believe it to be a net good. |
I am not even able to build several Anuglar 2 starter packs, because of errors like: exported variable 'xyz' has or is using name 'Subject' from external module rxjs which is built-in in angular 2. Thats the thing,.. so i wont talk here about 100 libraries which you have mentioned on your main page angular.io like PrimeNG,, Kendo,.. that ARE NOT ready for AOT. |
I think it's much more than just momentarily inconvenient. As Angular-CLI devs we will now have to audit every open source component we bring in and ensure that they are AoT-friendly before we can use them, even if we have no interest in making an AoT app. In my experience there will be many components that will never be updated so we'll just have to skip them and try to find something else. I don't think it's the "end of angular" but it's definitely a huge hassle. |
My immediate concern is that #2799 is still open, i.e. the interaction between AOT compilation and custom decorators critical to state management/side-effects solutions in two material libraries is not yet resolved. For the first time in the beta cycle, I have held off on upgrading, i.e. from beta.21 to beta.22, as it is not self-evident to me whether said issue is exacerbated with the latest release. So, if someone could shed some light on this particular aspect, I should be most indebted. |
For sure, idealy if everything was AOT compliant it would be
How so ? This is really something I don't understand. Last thing is, as @tomwanzek said, there's a huge concern of introducing the obligation to have our code AOT compliant when #2799 is still opened : Custom decorators are stripped off. I've been sticking with angular-cli since the beginning, even tho there are great starters out there that support AOT, lazy loading, hmr, etc for months. But I really like the idea behind angular-cli : Having a similar code base for every repo and making a tool common to every devs so it's easier to work on another project. I loved the decision and (huge) work done when switching from systemjs to webpack. But this time, it feels like this is a big decision with a deep impact on the community (+ existing projects) and we didn't see that coming. Could it be possible to have an issue opened to discuss that kind of update, even before the work gets started ? I don't know if asking community opinion for big changes is something common in open source world, but it'd probably be great and constructive ! :) |
@maxime1992 totally agree that it is odd to have this change in before having a fix for #2799. when I said it won't affect non angular libs I mean to say that if you are using jquery, moment, or something like that AOT doesn't affect it. |
I think having it enabled by default but able to be disabled should be the mantra going forward with some of these big "flag" type changes. Also, enforcing AOT compliance only makes sense to me if Angular itself did not support JIT. Perhaps they will with Angular 3 that will be the case. If it is, then this seems be best left for a 2.0 version of the cli. |
@born2net does the error go away with |
@born2net not relevant to this issue, but you need to |
I can only assume a lot more people are going to face issues as they will start moving to .22.
and here are the issues now.
I am not even thinking AOT at this point as I am sure many things I do are not going to be compatible with AOT, for example I used private in components for members which are accessed from the template, I know these need to be public, as one example. So really I just want to get JIT working with .22 so I can finally use --hmr which I have been waiting for, for sooo long... but no go. @hansl if you have a chance it would be awesome if you could use my project as a test bed for .22
and if you can get it working with .22, I'd buy u a beer :) (works great in .21 so I can't imagine it would be so difficult in .22) tx as always, Sean. |
@born2net extract your factory into an exported function. e.g. something like
|
tx for the reply so went ahead and converted to:
issue persists:
|
Getting the same kind of stuff here. There should really be a way to disable the AoT plugin and just use awesome-typescript-loader or ts-loader. |
I have found what causes this problem in my case: |
I am also facing similar issues, How can I downgrade to the angular-cli. |
|
still open on beta.23? |
It looks like beta.23 is not yet published to npm. I'll check if this works when new version will be avabile |
@kucharzyk yeah.. i tried to installl latest version via NPM install Git../tarball/master but i have got tons of errors, so this is propably not the correct way.. so we have to wait :-( i am waiting for that because ngrx/effects are greta, but they use decorators, and they are stripped down in current CLI versions. |
looks like this is affecting hmr usage too, now it does full reload on lazy-loaded components... |
@hansl have you already noticed problems with HMR on 22-1 and lazy routes ? or shall i create an issues with minimal repo? |
Adding the static analysis/AoT related issue(s) to the "breaking changes" section in the changelog would probably save some people trouble. |
To be clear -- is this a bug as far as the team is concerned, or is this how the cli will be compiling from beta 22 onward? That is to say:
I'd like to upgrade because of the speed improvements that have been made, but my project relies on some 3rd party libs that aren't AoT-ready. |
@rosslavery Pretty much. We're always looking for feedback, and we are really aware of the vacuum right now for developing AOT-compatible libraries. Give us the libraries that are not AOT compliant and we can contact them. We have a great developer relations team that can help those libraries move onto supporting AOT (every library developer I've met wants to, they just often don't know how or it isn't clear). |
AFAIK the issues are beyond just AOT, as just running static methods |
@born2net the issue that a lot of libs that have a forRoot method are having is that somewhere in that forRoot method they are doing something that isn't statically analyzable. Not saying I don't agree, just pointing out the issue is not calling static methods on modules |
material2 has a forRoot (and is currently buggy and cumbersome for AoT). |
I can confirm forRoot does not work... |
I can confirm that forRoot does work. Been using it in my lib and it works with no issues. |
Closing this as obsolete. We've been enforcing static analysis since Beta 22 now. |
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. |
OS?
El Capitan
Versions.
angular-cli: 1.0.0-beta.22
node: 6.6.0
os: darwin x64
Repro steps.
run
ng serve
The log given by the failure.
Mention any other details that might be useful.
The text was updated successfully, but these errors were encountered: