not working with AoT
See original GitHub issueHi,
i get following error when i try to compile with AoT:
ERROR in Error: Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 4:22 in the original .ts file), resolving symbol flipInY in C:/workspace/Node/EagleWeb/node_modules/ng-animate/lib/flippers.d.ts, resolving symbol flipInY in C:/workspace/Node/EagleWeb/node_modules/ng-animate/lib/index.d.ts, resolving symbol animationLogin in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts, resolving symbol animationLogin in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts, resolving symbol animationLogin in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts, resolving symbol animationLogin in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts, resolving symbol LoginPageComponent in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts, resolving symbol LoginPageComponent in C:/workspace/Node/EagleWeb/src/app/atomic/pages/login-page/login.page.ts
at positionalError (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:25243:2)
at simplifyInContext (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:25086:9)
at StaticReflector.simplify (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:25100:7)
at StaticReflector.annotations (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:24528:38)
at NgModuleResolver.resolve (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:14866:34)
at CompileMetadataResolver.getNgModuleMetadata (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:15521:58)
at addNgModule (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\bundles\compiler.umd.js:24408:58)
at C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\bundles\compiler.umd.js:24419:14
at Array.forEach (<anonymous>)
at _createNgModules (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:24388:8)
at analyzeNgModules (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\bundles\compiler.umd.js:24293:14)
at analyzeAndValidateNgModules (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\@angular\compiler.es5.js:24273:19)
at AotCompiler.analyzeModulesAsync (C:\workspace\Node\EagleWeb\node_modules\@angular\compiler\bundles\compiler.umd.js:23937:46)
at CodeGenerator.codegen (C:\workspace\Node\EagleWeb\packages\compiler-cli\src\codegen.ts:41:10)
at Function.NgTools_InternalApi_NG_2.codeGen (C:\workspace\Node\EagleWeb\packages\compiler-cli\src\ngtools_api.ts:112:26)
at _donePromise.Promise.resolve.then (C:\workspace\Node\EagleWeb\node_modules\@ngtools\webpack\src\plugin.js:386:44)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:667:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Sample Code:
export function animationLogin(): AnimationTriggerMetadata {
return trigger('login', [
state(AnimationElementState.active, style({ opacity: 1 })),
state(AnimationElementState.inactive, style({ opacity: 0 })),
transition('inactive => active', useAnimation(flipInY, {
params: {
timing: 0.5
}
})),
transition('active => inactive', useAnimation(flipOutX, {
params: {
timing: 0.5
}
}))
]);
}
@Component({
selector: 'ta-login-page',
styleUrls: ['./login.page.scss'],
templateUrl: './login.page.pug',
animations: [
fadeInOut,
animationFader(),
animationZoomIn(),
animationLogin()
]
})
without AoT it works fine.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Angular5:compileModuleAndAllComponentsSync not ...
The JIT compiler is generally not available from AoT mode, here is a workaround taken from Angular's integration example.
Read more >ng build --no-aot --prod does not work in angular-cli 1.5
The problem is buildOptimizer still enabled in JIT for --prod , try ng build --prod --aot=false --build-optimizer=false could solve it. Likely ...
Read more >Angular: Writing AoT-friendly applications | by David
Ahead-of-Time (AoT) compilation is a powerful tool. Sharing developer experiences from delivering an Angular2… ... And last, don't try too get too much...
Read more >build issue in angular 11 when enabling --aot
Hi Team,. When we enable aot in build build getting failed and same working in local. can you please suggest. npm ERR! code...
Read more >Ahead-of-time (AOT) compilation
The Angular ahead-of-time (AOT) compiler converts your Angular HTML and ... For help in understanding and resolving these problems, see AOT Metadata Errors....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve managed to support AOT and updated peerDependencies for any version of Angular >= 4.2. Work has been done in #11 . I’ve also published a new version
0.3.2so let me know if it has been solved also for you. Then I’ll merge the PR.I’ve tried adding support for AOT but as always it’s a very painful and frustrating experience. There are currently strong limits with the AOT compiler
ngcas reported here on Angular repo.So in the end I wasn’t able to get it work without trying a complete rework of the lib. Currently I make a huge use of
higher-order functionsto avoid code duplication. Basically the compiler throws when I use a generic animation like in bounceInDirection, whereas it’s fine a not-generic animation with hardcoded values. Writing all the animations with the latter approach would lead to a huge duplication.Basically I won’t support AOT for now, I’m fed up with Angular AOT shit. If anyone wants to try, PRs are welcome and I’d be glad to help, but I spent too much time myself with AOT.
For anyone else I recommend copying the implementation from lib and creating a not-generic animation with your hardcoded values.