Skip to content
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

Please add Ahead of time compile support #758

Closed
chriswep opened this issue Oct 11, 2016 · 6 comments
Closed

Please add Ahead of time compile support #758

chriswep opened this issue Oct 11, 2016 · 6 comments

Comments

@chriswep
Copy link

currently apollo-client breaks the compilation with the angular compiler "ngc". As far as i could see the main problem would be that ApolloClient is a default export which breaks static analyzation. See this helpful post for details: https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5#.pbg52i3qt

I made quick fix to a copy of the apolloclient-source in my project in this regard which seemed to work. I also includes some "hacks" to remove circular dependencies to make the library compatible with rollup. Seeing that you do a refactor right now i think its no use to create a proper pull request for that? Otherwise just ask.

@stubailo
Copy link
Contributor

Wow, it's really silly that ahead of time compilation doesn't work with default exports. Is it enough to add a named export in addition to the default one?

@chriswep
Copy link
Author

@stubailo i think it would work, this is what I also did first. but I wouldn't recommend it. If any library or code imports the default export it would still brake on AOT. At least that's what happened to me (if I interpreted the errors correctly).

@stubailo
Copy link
Contributor

That just seems offensive - you can't use AOT in your app if any code in any dependency uses a default import? I absolutely do not think that's a reasonable restriction for a build tool to impose on the user. Is there a relevant issue somewhere I can comment on?

@chriswep
Copy link
Author

don't take my word on it, i'm not very deep into this whole topic. but it somehow makes sense that you can't analyze the code statically if exports are not named. its also possible that this only applies to stuff you include into your root module.

the place to discuss this would probably be at the compiler[-cli] repo of angular.

@stubailo
Copy link
Contributor

Rollup definitely does nice static analysis with default exports. I'd admit that it might be harder but it sure isn't impossible, and a tool like this IMO has the responsibility to work with standard language features. I'll take a look there.

@kamilkisiela
Copy link
Contributor

They're going to support it angular/angular#11402

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants