Skip to content

Commit 2e26a22

Browse files
committed
feat: support angular v20
BREAKING CHANGE: requires a minimum version of Angular 20
1 parent 830d89c commit 2e26a22

File tree

13 files changed

+6174
-8185
lines changed

13 files changed

+6174
-8185
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.16.0

angular.json

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"prefix": "app",
1212
"architect": {
1313
"build": {
14-
"builder": "@angular-devkit/build-angular:browser",
14+
"builder": "@angular/build:application",
1515
"options": {
16-
"outputPath": "dist/demo",
16+
"outputPath": {
17+
"base": "dist/demo"
18+
},
1719
"index": "demo/index.html",
18-
"main": "demo/main.ts",
1920
"polyfills": [
2021
"zone.js"
2122
],
@@ -33,18 +34,18 @@
3334
}
3435
],
3536
"styles": [
37+
"@angular/material/prebuilt-themes/deeppurple-amber.css",
3638
"demo/styles.css"
3739
],
38-
"scripts": []
40+
"scripts": [],
41+
"browser": "demo/main.ts"
3942
},
4043
"configurations": {
4144
"production": {
4245
"outputHashing": "all"
4346
},
4447
"development": {
45-
"buildOptimizer": false,
4648
"optimization": false,
47-
"vendorChunk": true,
4849
"extractLicenses": false,
4950
"sourceMap": true,
5051
"namedChunks": true
@@ -53,21 +54,21 @@
5354
"defaultConfiguration": "production"
5455
},
5556
"serve": {
56-
"builder": "@angular-devkit/build-angular:dev-server",
57+
"builder": "@angular/build:dev-server",
5758
"configurations": {
5859
"production": {
59-
"browserTarget": "ngx-timeago-demo:build:production"
60+
"buildTarget": "ngx-timeago-demo:build:production"
6061
},
6162
"development": {
62-
"browserTarget": "ngx-timeago-demo:build:development"
63+
"buildTarget": "ngx-timeago-demo:build:development"
6364
}
6465
},
6566
"defaultConfiguration": "development"
6667
},
6768
"extract-i18n": {
68-
"builder": "@angular-devkit/build-angular:extract-i18n",
69+
"builder": "@angular/build:extract-i18n",
6970
"options": {
70-
"browserTarget": "ngx-timeago-demo:build"
71+
"buildTarget": "ngx-timeago-demo:build"
7172
}
7273
}
7374
}
@@ -79,7 +80,7 @@
7980
"prefix": "lib",
8081
"architect": {
8182
"build": {
82-
"builder": "@angular-devkit/build-angular:ng-packagr",
83+
"builder": "@angular/build:ng-packagr",
8384
"options": {
8485
"project": "lib/ng-package.json"
8586
},
@@ -94,7 +95,7 @@
9495
"defaultConfiguration": "production"
9596
},
9697
"test": {
97-
"builder": "@angular-devkit/build-angular:karma",
98+
"builder": "@angular/build:karma",
9899
"options": {
99100
"tsConfig": "lib/tsconfig.spec.json",
100101
"polyfills": [
@@ -108,5 +109,31 @@
108109
},
109110
"cli": {
110111
"analytics": false
112+
},
113+
"schematics": {
114+
"@schematics/angular:component": {
115+
"type": "component"
116+
},
117+
"@schematics/angular:directive": {
118+
"type": "directive"
119+
},
120+
"@schematics/angular:service": {
121+
"type": "service"
122+
},
123+
"@schematics/angular:guard": {
124+
"typeSeparator": "."
125+
},
126+
"@schematics/angular:interceptor": {
127+
"typeSeparator": "."
128+
},
129+
"@schematics/angular:module": {
130+
"typeSeparator": "."
131+
},
132+
"@schematics/angular:pipe": {
133+
"typeSeparator": "."
134+
},
135+
"@schematics/angular:resolver": {
136+
"typeSeparator": "."
137+
}
111138
}
112139
}

demo/app/app.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component, ChangeDetectionStrategy } from '@angular/core';
22

33
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html',
4+
selector: 'app-root',
5+
templateUrl: './app.component.html',
6+
standalone: false
67
})
78
export class AppComponent {
89
date = Date.now() - 55000;

demo/app/child/child.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { strings as frenchStrings } from 'ngx-timeago/language-strings/fr';
66
import { strings as frenchShortStrings } from 'ngx-timeago/language-strings/fr-short';
77

88
@Component({
9-
selector: 'app-child',
10-
templateUrl: './child.component.html',
11-
changeDetection: ChangeDetectionStrategy.OnPush
9+
selector: 'app-child',
10+
templateUrl: './child.component.html',
11+
changeDetection: ChangeDetectionStrategy.OnPush,
12+
standalone: false
1213
})
1314
export class ChildComponent {
1415
date = Date.now() - 55000;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Component, ChangeDetectionStrategy } from '@angular/core';
22

33
@Component({
4-
selector: 'app-foo',
5-
template: `
4+
selector: 'app-foo',
5+
template: `
66
<h2> OnPush Component </h2>
77
<div timeago [date]="2671200000" [live]="true"></div>
88
`,
9-
changeDetection: ChangeDetectionStrategy.OnPush
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
standalone: false
1011
})
1112
export class FooComponent {
1213
}

demo/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "~@angular/material/prebuilt-themes/deeppurple-amber.css";
1+
/* Angular Material theme imported via angular.json */
22
@import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
33

44
.header-image {

lib/src/tests/directive.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ const strings: IL10nsStrings = {
2424

2525
@Injectable()
2626
@Component({
27-
selector: 'app-root',
28-
template: `
27+
selector: 'app-root',
28+
template: `
2929
<div #static timeago [date]="date" [live]="false"></div>
3030
<div #live timeago [date]="date" [live]="true"></div>
3131
<div #var timeago [date]="date" [live]="isLive"></div>
32-
`
32+
`,
33+
standalone: false
3334
})
3435
class AppComponent {
3536
@ViewChild('static') static: ElementRef;
@@ -56,9 +57,9 @@ describe('TimeagoDirective', () => {
5657
providers: [TimeagoIntl],
5758
declarations: [AppComponent]
5859
});
59-
clock = TestBed.get(TimeagoClock);
60-
formatter = TestBed.get(TimeagoFormatter);
61-
intl = TestBed.get(TimeagoIntl);
60+
clock = TestBed.inject(TimeagoClock);
61+
formatter = TestBed.inject(TimeagoFormatter);
62+
intl = TestBed.inject(TimeagoIntl);
6263
intl.strings = { ...strings };
6364

6465
});

lib/src/tests/pipe.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ class FakeChangeDetectorRef extends ChangeDetectorRef {
4949

5050
@Injectable()
5151
@Component({
52-
selector: 'app-root',
53-
template: `
52+
selector: 'app-root',
53+
template: `
5454
<div #static>{{date | timeago:false}}</div>
5555
<div #live>{{date | timeago:true}}</div>
5656
<div #var>{{date | timeago:isLive}}</div>
5757
`,
58+
standalone: false
5859
})
5960
class AppComponent {
6061
@ViewChild('static') static: ElementRef;
@@ -84,9 +85,9 @@ describe('TimeagoPipe', () => {
8485
declarations: [AppComponent]
8586
});
8687
date = Date.now() - 1000;
87-
clock = TestBed.get(TimeagoClock);
88-
formatter = TestBed.get(TimeagoFormatter);
89-
intl = TestBed.get(TimeagoIntl);
88+
clock = TestBed.inject(TimeagoClock);
89+
formatter = TestBed.inject(TimeagoFormatter);
90+
intl = TestBed.inject(TimeagoIntl);
9091
intl.strings = { ...strings };
9192
ref = new FakeChangeDetectorRef();
9293
});

lib/src/timeago.directive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import { TimeagoIntl } from './timeago.intl';
77
import { isDefined, coerceBooleanProperty, dateParser } from './util';
88

99
@Directive({
10-
selector: '[timeago]',
11-
exportAs: 'timeago',
10+
selector: '[timeago]',
11+
exportAs: 'timeago',
12+
standalone: false
1213
})
1314
export class TimeagoDirective implements OnChanges, OnDestroy {
1415
private intlSubscription: Subscription;

lib/src/timeago.pipe.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { filter } from 'rxjs/operators';
88

99
@Injectable()
1010
@Pipe({
11-
name: 'timeago',
12-
pure: false, // required to update the value when stateChanges emits
11+
name: 'timeago',
12+
pure: false,
13+
standalone: false
1314
})
1415
export class TimeagoPipe implements PipeTransform, OnDestroy {
1516
private intlSubscription: Subscription;

0 commit comments

Comments
 (0)