Skip to content

Commit

Permalink
fix(vite-plugin-angular): adjust compiled output to be more concise (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc authored Jan 9, 2024
1 parent f348b4b commit 7ac2d23
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ import { signal } from "@angular/core";
<p>{ a }</p>
<p>{ b }</p>
<p>{ c }</p>
<p>{{ test }}</p>\`,
imports: []
<p>{{ test }}</p>\`
})
export default class AnalogNgEntity {
export default class VirtualAnalogComponent {
constructor() {
let test: string;
let test;
setTimeout(() => {
test = 'test';
}, 1000)
const counter = signal(0);
this.counter = counter;
const counter = (this.counter = signal(0));
const [a, b, , c = 4] = [1, 2, 3];
this.a = a;
this.b = b;
Expand All @@ -36,7 +34,6 @@ export default class AnalogNgEntity {
}
protected Math = Math;
protected counter;
protected a;
protected b;
protected c;
Expand All @@ -52,16 +49,23 @@ import { inject, ElementRef, afterNextRender } from "@angular/core";
standalone: true,
selector: 'input[directive]'
})
export default class AnalogNgEntity {
export default class VirtualAnalogDirective {
constructor() {
const elRef = inject(ElementRef);
this.elRef = elRef;
const elRef = (this.elRef = inject(ElementRef));
afterNextRender(() => {
elRef.nativeElement.focus();
});
this.onInit = () => {
console.log('init code');
}
effect(() => {
console.log('just some effect');
});
}
protected elRef;
ngOnInit() {
this.onInit();
}
}
"
`;
8 changes: 8 additions & 0 deletions packages/vite-plugin-angular/src/lib/authoring/ng.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ const elRef = inject(ElementRef);
afterNextRender(() => {
elRef.nativeElement.focus();
});
onInit(() => {
console.log('init code');
});
effect(() => {
console.log('just some effect');
});
</script>
`;

Expand Down
Loading

0 comments on commit 7ac2d23

Please sign in to comment.