No AOT-compatible way to reuse animation definitions
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
As far as I can tell there is currently no way to reuse Angular animations in a way that is compatible with the AOT compiler. When using JIT, I could export some static AnimationEntryMetadata objects and then reference these in my component decorators, e.g. animations: [Animations.EXPAND_WIDTH].
This doesn’t work in AOT - animations’ state metadata will not be generated correctly. I don’t want to redeclare the animation in full in every component decorator as they can be 5-15 lines each and are all the same across my app.
Expected behavior AOT compiler should allow for the reuse of animation metadata.
Minimal reproduction of the problem with instructions Create an AOT project, create some static animation definitions and export them from one file. Import them into a component definition and reference one of the animations in the compiler’s metadata. AOT compilation will fail.
What is the motivation / use case for changing the behavior? DRY principles, maintainability, desire to make reusable animation libraries
Please tell us about your environment: Windows 7, WebStorm
-
Angular version: 2.2.0
-
Browser: all
-
Language: all
-
Node (for AoT issues):
node --version= 5.8.0
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:11 (9 by maintainers)

Top Related StackOverflow Question
I created an issue for the error message, #13132, and am closing this issue in favor of that one.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.