The Log decorator/annotation does not support AoT compilation
russcarver opened this issue ยท 6 comments
At https://github.com/k1r0s/kaop-ts/blob/master/docs/examples.md#log-decorator (and related linked documentation), you give an example that does not pass Angular5's AoT compilation. To get this to work, it should be:
import { afterMethod, IMetadata } from 'kaop-ts';
export function Log(): Function {
return afterMethod((meta: IMetadata) => {
const methodName = `${meta.target.constructor.name}::${meta.key}`;
console.info(`log-decorator: ${methodName} invoked!`);
console.info(`log-decorator: ${methodName} arguments -> `, meta.args);
console.info(`log-decorator: ${methodName} result -> `, meta.result);
});
}
Then, the decorator should be used as @Log()
instead of @Log
.
Hi @russcarver
I didn't try Angular5 yet. I worked with Angular 2/4
Seems like AOT build is refusing to recognize some custom decorators as I can see elsewhere
Feel free to PR your solution to the docs
https://github.com/k1r0s/kaop-ts/blob/master/docs/examples.md
@k1r0s I think it is a bug - in v3.1.3
.
when I was trying update to v3.1.3
my build was broken similar to @russcarver
currently I'm in production with angular@5.2.6
and AOT and kaop-ts@3.1.2
.
thanks for the tip @voznik
I have to investigate this in deep.
The only change between these versions was that typings path was missing from package.json. That means 3.1.2
doesn't provide any call signatures and that could be the reason why this version is bypassing AOT compiler
@voznik can you share your package.json I tried using 5.2.6 with 3.12 and AOT and it's still failing when exporting a wrapper to the afterMethod
Hey
I want to fix this but im not able to reproduce the issue.
I created a project with the latest version of @angular/cli
Then I installed kaop-ts (latest version)
This is what I have so far:
k1r0s@k1r0s-K52JU:~/Works/kaop-fix$ npm ls | grep angular
โโโฌ @angular/animations@5.2.9
โโโฌ @angular/cli@1.7.4
โ โโโฌ @angular-devkit/build-optimizer@0.3.2
โ โโโฌ @angular-devkit/core@0.3.2
โ โโโ @angular-devkit/schematics@0.3.2
โ โโโฌ @schematics/angular@0.3.2
โโโ @angular/common@5.2.9
โโโ @angular/compiler@5.2.9
โโโฌ @angular/compiler-cli@5.2.9
โโโ @angular/core@5.2.9
โโโ @angular/forms@5.2.9
โโโ @angular/http@5.2.9
โโโ @angular/language-service@5.2.9
โโโ @angular/platform-browser@5.2.9
โโโ @angular/platform-browser-dynamic@5.2.9
โโโ @angular/router@5.2.9
Then I added an advice here
import { Component, OnInit } from '@angular/core';
import { afterMethod } from 'kaop-ts';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'app';
@afterMethod(meta => console.log("yooooolo"))
public ngOnInit() {
}
}
code works and Im able to run ng build --aot
smoothly
can anyone confirm?
closing this due to inactivity