-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
AOT support #871
Comments
@ammar91 is this happening with the beta 15? |
@moxival Yes. |
@ammar91 we haven't taken the plunge in AOT yet so I can't really help, sorry. Maybe @cagataycivici can give some I insight? |
@cagataycivici Could you please put your thoughts on this? |
Seems to have to do with not having a metadata.json file. Probably just have to wait until they have time to do this. |
Now that the Angular 2 officially released. It would be good to have it working in the next release. |
Any chance of having it functional in beta 16? |
Will this be available in the next beta, or later? |
@qdouble How does material 2 and other 3rd party packages run fine in AOT mode? I'm even able to compile my application in AOT mode if I remove PNG dependency, isn't that mean PNG not AOT compatible yet? |
@ammar91 I'm not sure of every step 3rd party developers have to take...the main problem may be that a lot of these libraries were created before AOT was even a consideration and need to be updated. As far as the png thing, link to a reproduction of it over on my repo and I can look at it, may need a loader or something else, I haven't dealt with that yet |
According to this github issue angular/angular#11889 , it looks like the 3rd party module must ship the metadata files. |
We haven't managed to spare time to look into this yet, we'd appreciate feedback on how to add AOT compatibility. |
The problem is also mentioned in this issue angular/angular#11262 |
@cagataycivici Looks like these are the steps required to generate metadata files https://medium.com/@isaacplmann/getting-your-angular-2-library-ready-for-aot-90d1347bcad#.mtna6ixy8 |
Thanks we'll review after beta17. |
@cagataycivici I made a pull request. Please check #1004 |
AOT support work has started and we definitely need feedback. As far as I understand metadata files are only required for non-ts files, from the docs;
@ammar91's PR adds metadata files which we'd like to avoid maintaining, my initial idea is make sure sure ngc properly compiles our ts files and also ship the ts files in the npm package because until now we only ship js. When the ts files of PrimeNG will be in npm and as a result in your app's node_modules, I'm hoping you will be able to compile your app with AOT without need for metadata files. Of course, we'll make sure ngc compiles our ts without issues before releasing. Feedback is welcome. |
Hi @cagataycivici, |
@cagataycivici I agree, metadata.json should not be under version control. I believe you could generate those before publishing to npm. This is how ng-bootstrap and angular material doing as well. |
Also, AMO shipping the ts files in npm package would not be an ideal solution. |
My current decision is not to include ts and generate metadata.json files when publishing. I'd appreciate if you could point me to the process of generating these files. |
@cagataycivici Sure, These are the steps for generating the files
Eg:
To
And add these in tsconfig so it looks for the typings file in the correct location
You may notice core-js is not listed, that is because it may throw
You may get several errors which are mostly related to access modifiers mentioned in the below article (3rd point, that says private, protected accessors should be changed to public for any members accessed from template) After fixing those, you should be able to successfully compile with ngc. Hope that helps! |
Thanks, I'll work on this soon. |
Work has started, I'm doing an entire code review to remove "any" types and check aot compatibility. As a side note, I had to add "skipMetadataEmit" : false to get the metadata json files also somehow haven't done some steps like number 5 but it worked fine. |
Quick question, does setting "noImplicitAny" in tsconfig-aot.json as false have any impact on AOT metadata json files or ngFactory? Right now there are aot compilation issues due to usage of protected-private variables in inline templates of components as expected, my main focus is on that to get AOT ready instead of replacing "any" with actual type which can be done with a refactor later. |
Alright, I've done the changes for AOT support. |
@cagataycivici That's Great, There should be no impact by setting "noImplicitAny" to false. |
hello @cagataycivici You said on this post that primeng is ready for aot. Nevertheless, I cannot compile even with a simple import (not using any component on html) using the follow primeng version: module @NgModule({ component tsconfig-aot.json export default {
}, When running: The terminal throws: � 'CheckboxModule' is not exported by node_modules\primeng\primeng.js When I check the primeng folder on my node_module. I see that there are no .metadata.json info overthere. These files in source libraries is needed for aot. Could you include them on your release? The follow links could be useful in order to find the solution: Thank you in advance. |
Hi @cagataycivici I am facing the same issue as @Pilukina, is aot in 2.0 branch? By the way PrimeNg is fantastic! |
@Pilukina @edwinquaihoi |
Thank you so much for your answer. The bug is solved by primeng, they have included the needed .metadata.json for aot on version 2.0.3. Nevertheless the components could be imported and compiled using both paths. |
I could not success to run rollup (after AOT compilation) my ang2 app with primeNG modules. I am getting the error below for all modules:
Anyone knows how we can overcome the issue? |
I'm using primeng v2.0.3, The node_modules\primeng\components\editor\editor.js exports exports.EditorModule = EditorModule; on line 139. Could you check which version of primeng are you using and if the metadata.json is included? |
Hi Pilukina, I am simply following the official guidelines for Ang2 AOT. There are 2 steps, 1st is ngc, 2nd is rollup: https://angular.io/docs/ts/latest/cookbook/aot-compiler.html I am using 2.0.5, ngc compiles but rollup throws error. Sorry for missleading.
|
I'm afraid I can't help you. Nevertheless, I recommend you directly write a new topic on ngprime forum: https://forum.primefaces.org/viewforum.php?f=35 |
Actually there is a workaround to specify the named exports in the rollup-config like this: plugins: [
commonjs({
include: 'node_modules/**',
namedExports: {
// Add every import you need from primeng to the list
'node_modules/primeng/primeng.js': ['SharedModule', 'DataTableModule', 'DataTable']
}
})
] |
Thanks, that solved the problem. |
it solves the problem with a work around. The primeng modules should 'export' stuff properly. |
Could this be hot fixed please? PrimeNG is not properly exporting stuff. |
@cagataycivici can you please reopen this issue since it seems to still not be fixed? |
I'm trying to compile my application with AOT compiler but getting an error with
Primeng modules
.My App
SharedModule
exportprimeng modules
that my app require includingAny thoughts?
The text was updated successfully, but these errors were encountered: