diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-31 14:34:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-11 15:02:33 +0200 |
commit | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch) | |
tree | e4510b39bdac9c318fdb4b47018d08f15368b8f0 /client/src/app/+my-account | |
parent | 04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff) | |
download | PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip |
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge
conflicts, but it's a major step forward:
* Server can be faster at startup because imports() are async and we can
easily lazy import big modules
* Angular doesn't seem to support ES import (with .js extension), so we
had to correctly organize peertube into a monorepo:
* Use yarn workspace feature
* Use typescript reference projects for dependencies
* Shared projects have been moved into "packages", each one is now a
node module (with a dedicated package.json/tsconfig.json)
* server/tools have been moved into apps/ and is now a dedicated app
bundled and published on NPM so users don't have to build peertube
cli tools manually
* server/tests have been moved into packages/ so we don't compile
them every time we want to run the server
* Use isolatedModule option:
* Had to move from const enum to const
(https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
* Had to explictely specify "type" imports when used in decorators
* Prefer tsx (that uses esbuild under the hood) instead of ts-node to
load typescript files (tests with mocha or scripts):
* To reduce test complexity as esbuild doesn't support decorator
metadata, we only test server files that do not import server
models
* We still build tests files into js files for a faster CI
* Remove unmaintained peertube CLI import script
* Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'client/src/app/+my-account')
6 files changed, 8 insertions, 9 deletions
diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts index e88cdd228..281a12eda 100644 --- a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts +++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { AuthService, ConfirmService, Notifier, ScopedTokensService } from '@app/core' | 2 | import { AuthService, ConfirmService, Notifier, ScopedTokensService } from '@app/core' |
3 | import { VideoService } from '@app/shared/shared-main' | 3 | import { VideoService } from '@app/shared/shared-main' |
4 | import { FeedFormat } from '@shared/models' | 4 | import { FeedFormat, ScopedToken } from '@peertube/peertube-models' |
5 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | ||
6 | import { environment } from '../../../environments/environment' | 5 | import { environment } from '../../../environments/environment' |
7 | 6 | ||
8 | @Component({ | 7 | @Component({ |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts index 1e8fa2a56..7bbd240d0 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts | |||
@@ -4,7 +4,7 @@ import { Component, OnInit } from '@angular/core' | |||
4 | import { AuthService, Notifier, ServerService, UserService } from '@app/core' | 4 | import { AuthService, Notifier, ServerService, UserService } from '@app/core' |
5 | import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' | 5 | import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' |
6 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' | 6 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
7 | import { HttpStatusCode, User } from '@shared/models' | 7 | import { HttpStatusCode, User } from '@peertube/peertube-models' |
8 | 8 | ||
9 | @Component({ | 9 | @Component({ |
10 | selector: 'my-account-change-email', | 10 | selector: 'my-account-change-email', |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index 805d50070..f916740be 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts | |||
@@ -7,7 +7,7 @@ import { | |||
7 | USER_PASSWORD_VALIDATOR | 7 | USER_PASSWORD_VALIDATOR |
8 | } from '@app/shared/form-validators/user-validators' | 8 | } from '@app/shared/form-validators/user-validators' |
9 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' | 9 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
10 | import { HttpStatusCode, User } from '@shared/models' | 10 | import { HttpStatusCode, User } from '@peertube/peertube-models' |
11 | 11 | ||
12 | @Component({ | 12 | @Component({ |
13 | selector: 'my-account-change-password', | 13 | selector: 'my-account-change-password', |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts index 381d18922..bf6accc3e 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-email-preferences/my-account-email-preferences.component.ts | |||
@@ -2,7 +2,7 @@ import { Subject } from 'rxjs' | |||
2 | import { Component, Input, OnInit } from '@angular/core' | 2 | import { Component, Input, OnInit } from '@angular/core' |
3 | import { Notifier, UserService } from '@app/core' | 3 | import { Notifier, UserService } from '@app/core' |
4 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' | 4 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
5 | import { User, UserUpdateMe } from '@shared/models' | 5 | import { User, UserUpdateMe } from '@peertube/peertube-models' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-account-email-preferences', | 8 | selector: 'my-account-email-preferences', |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts index 2adc276a9..f4181340d 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts | |||
@@ -3,8 +3,8 @@ import { Subject } from 'rxjs' | |||
3 | import { Component, Input, OnInit } from '@angular/core' | 3 | import { Component, Input, OnInit } from '@angular/core' |
4 | import { Notifier, ServerService, User } from '@app/core' | 4 | import { Notifier, ServerService, User } from '@app/core' |
5 | import { UserNotificationService } from '@app/shared/shared-main' | 5 | import { UserNotificationService } from '@app/shared/shared-main' |
6 | import { objectKeysTyped } from '@shared/core-utils' | 6 | import { objectKeysTyped } from '@peertube/peertube-core-utils' |
7 | import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models' | 7 | import { UserNotificationSetting, UserNotificationSettingValue, UserRight, UserRightType } from '@peertube/peertube-models' |
8 | 8 | ||
9 | @Component({ | 9 | @Component({ |
10 | selector: 'my-account-notification-preferences', | 10 | selector: 'my-account-notification-preferences', |
@@ -19,7 +19,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { | |||
19 | emailNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} | 19 | emailNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} |
20 | webNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} | 20 | webNotifications: { [ id in keyof UserNotificationSetting ]?: boolean } = {} |
21 | labelNotifications: { [ id in keyof UserNotificationSetting ]?: string } = {} | 21 | labelNotifications: { [ id in keyof UserNotificationSetting ]?: string } = {} |
22 | rightNotifications: { [ id in keyof Partial<UserNotificationSetting> ]?: UserRight } = {} | 22 | rightNotifications: { [ id in keyof Partial<UserNotificationSetting> ]?: UserRightType } = {} |
23 | emailEnabled = false | 23 | emailEnabled = false |
24 | 24 | ||
25 | private savePreferences = debounce(this.savePreferencesImpl.bind(this), 500) | 25 | private savePreferences = debounce(this.savePreferencesImpl.bind(this), 500) |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts index a276bb126..4b3b33bcc 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts | |||
@@ -3,7 +3,7 @@ import { HttpErrorResponse } from '@angular/common/http' | |||
3 | import { AfterViewChecked, Component, OnInit } from '@angular/core' | 3 | import { AfterViewChecked, Component, OnInit } from '@angular/core' |
4 | import { AuthService, Notifier, User, UserService } from '@app/core' | 4 | import { AuthService, Notifier, User, UserService } from '@app/core' |
5 | import { genericUploadErrorHandler } from '@app/helpers' | 5 | import { genericUploadErrorHandler } from '@app/helpers' |
6 | import { shallowCopy } from '@shared/core-utils' | 6 | import { shallowCopy } from '@peertube/peertube-core-utils' |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'my-account-settings', | 9 | selector: 'my-account-settings', |