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 /package.json | |
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 'package.json')
-rw-r--r-- | package.json | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/package.json b/package.json index 7573232a1..89f8fd4ed 100644 --- a/package.json +++ b/package.json | |||
@@ -8,9 +8,7 @@ | |||
8 | "node": ">=16.x", | 8 | "node": ">=16.x", |
9 | "yarn": ">=1.x" | 9 | "yarn": ">=1.x" |
10 | }, | 10 | }, |
11 | "bin": { | 11 | "type": "module", |
12 | "peertube": "dist/server/tools/peertube.js" | ||
13 | }, | ||
14 | "author": { | 12 | "author": { |
15 | "name": "Chocobozzz", | 13 | "name": "Chocobozzz", |
16 | "email": "chocobozzz@framasoft.org", | 14 | "email": "chocobozzz@framasoft.org", |
@@ -21,49 +19,60 @@ | |||
21 | "url": "git+https://github.com/Chocobozzz/PeerTube.git" | 19 | "url": "git+https://github.com/Chocobozzz/PeerTube.git" |
22 | }, | 20 | }, |
23 | "typings": "*.d.ts", | 21 | "typings": "*.d.ts", |
22 | "workspaces": [ | ||
23 | "packages/*", | ||
24 | "server" | ||
25 | ], | ||
24 | "scripts": { | 26 | "scripts": { |
25 | "e2e:browserstack": "bash ./scripts/e2e/browserstack.sh", | 27 | "e2e:browserstack": "bash ./scripts/e2e/browserstack.sh", |
26 | "e2e:local": "bash ./scripts/e2e/local.sh", | 28 | "e2e:local": "bash ./scripts/e2e/local.sh", |
27 | "setup:cli": "bash ./scripts/setup/cli.sh", | ||
28 | "build": "bash ./scripts/build/index.sh", | 29 | "build": "bash ./scripts/build/index.sh", |
29 | "build:embed": "bash ./scripts/build/embed.sh", | 30 | "build:embed": "bash ./scripts/build/embed.sh", |
30 | "build:server": "bash ./scripts/build/server.sh", | 31 | "build:server": "bash ./scripts/build/server.sh", |
31 | "build:client": "bash ./scripts/build/client.sh", | 32 | "build:client": "bash ./scripts/build/client.sh", |
32 | "build:peertube-runner": "bash ./scripts/build/peertube-runner.sh", | 33 | "build:peertube-runner": "bash ./scripts/build/peertube-runner.sh", |
34 | "build:peertube-cli": "bash ./scripts/build/peertube-cli.sh", | ||
35 | "build:tests": "bash ./scripts/build/tests.sh", | ||
33 | "clean:client": "bash ./scripts/clean/client/index.sh", | 36 | "clean:client": "bash ./scripts/clean/client/index.sh", |
34 | "clean:server:test": "bash ./scripts/clean/server/test.sh", | 37 | "clean:server:test": "bash ./scripts/clean/server/test.sh", |
35 | "i18n:update": "bash ./scripts/i18n/update.sh", | 38 | "i18n:update": "bash ./scripts/i18n/update.sh", |
36 | "plugin:install": "node ./dist/scripts/plugin/install.js", | ||
37 | "plugin:uninstall": "node ./dist/scripts/plugin/uninstall.js", | ||
38 | "i18n:create-custom-files": "node ./dist/scripts/i18n/create-custom-files.js", | ||
39 | "reset-password": "node ./dist/scripts/reset-password.js", | ||
40 | "dev": "bash ./scripts/dev/index.sh", | 39 | "dev": "bash ./scripts/dev/index.sh", |
41 | "dev:server": "bash ./scripts/dev/server.sh", | 40 | "dev:server": "bash ./scripts/dev/server.sh", |
42 | "dev:embed": "bash ./scripts/dev/embed.sh", | 41 | "dev:embed": "bash ./scripts/dev/embed.sh", |
43 | "dev:client": "bash ./scripts/dev/client.sh", | 42 | "dev:client": "bash ./scripts/dev/client.sh", |
44 | "dev:cli": "bash ./scripts/dev/cli.sh", | 43 | "dev:peertube-cli": "bash ./scripts/dev/peertube-cli.sh", |
45 | "dev:peertube-runner": "bash ./scripts/dev/peertube-runner.sh", | 44 | "dev:peertube-runner": "bash ./scripts/dev/peertube-runner.sh", |
46 | "start": "node dist/server", | 45 | "start": "node dist/server", |
47 | "start:server": "node dist/server --no-client", | 46 | "start:server": "node dist/server --no-client", |
47 | "plugin:install": "node ./dist/scripts/plugin/install.js", | ||
48 | "plugin:uninstall": "node ./dist/scripts/plugin/uninstall.js", | ||
49 | "reset-password": "node ./dist/scripts/reset-password.js", | ||
48 | "update-host": "node ./dist/scripts/update-host.js", | 50 | "update-host": "node ./dist/scripts/update-host.js", |
49 | "regenerate-thumbnails": "node ./dist/scripts/regenerate-thumbnails.js", | 51 | "regenerate-thumbnails": "node ./dist/scripts/regenerate-thumbnails.js", |
50 | "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js", | 52 | "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js", |
51 | "create-move-video-storage-job": "node ./dist/scripts/create-move-video-storage-job.js", | 53 | "create-move-video-storage-job": "node ./dist/scripts/create-move-video-storage-job.js", |
52 | "create-generate-storyboard-job": "node ./dist/scripts/create-generate-storyboard-job.js", | 54 | "create-generate-storyboard-job": "node ./dist/scripts/create-generate-storyboard-job.js", |
53 | "test": "bash ./scripts/test.sh", | ||
54 | "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh", | ||
55 | "generate-types-package": "ts-node ./packages/types/generate-package.ts", | ||
56 | "parse-log": "node ./dist/scripts/parse-log.js", | 55 | "parse-log": "node ./dist/scripts/parse-log.js", |
57 | "prune-storage": "node ./dist/scripts/prune-storage.js", | 56 | "prune-storage": "node ./dist/scripts/prune-storage.js", |
57 | "test": "bash ./scripts/test.sh", | ||
58 | "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh", | ||
59 | "generate-types-package": "tsx --conditions=peertube:tsx ./packages/types-generator/generate-package.ts", | ||
60 | "i18n:create-custom-files": "tsx --conditions=peertube:tsx ./scripts/i18n/create-custom-files.ts", | ||
61 | "benchmark-server": "tsx --conditions=peertube:tsx ./scripts/benchmark.ts", | ||
62 | "client:build-stats": "tsx --conditions=peertube:tsx ./scripts/client-build-stats.ts", | ||
63 | "generate-code-contributors": "tsx --conditions=peertube:tsx ./scripts/generate-code-contributors.ts", | ||
64 | "simulate-many-viewers": "tsx --conditions=peertube:tsx ./scripts/simulate-many-viewers.ts", | ||
58 | "postinstall": "test -n \"$NOCLIENT\" || (cd client && yarn install --pure-lockfile)", | 65 | "postinstall": "test -n \"$NOCLIENT\" || (cd client && yarn install --pure-lockfile)", |
59 | "tsc": "tsc", | 66 | "tsc": "tsc", |
60 | "commander": "commander", | 67 | "commander": "commander", |
61 | "lint": "npm run ci -- lint", | 68 | "lint": "npm run ci -- lint", |
62 | "ng": "ng", | 69 | "ng": "ng", |
63 | "ts-node": "ts-node", | 70 | "tsx": "tsx", |
64 | "eslint": "eslint", | 71 | "eslint": "eslint", |
65 | "resolve-tspaths": "resolve-tspaths", | 72 | "resolve-tspaths": "resolve-tspaths", |
66 | "resolve-tspaths:server": "npm run resolve-tspaths -- --project tsconfig.json --src . --out dist", | 73 | "resolve-tspaths:server": "npm run resolve-tspaths -- --project server/tsconfig.json --src server --out dist", |
74 | "resolve-tspaths:server-lib": "npm run resolve-tspaths -- --project server/tsconfig.lib.json --src server --out server/dist", | ||
75 | "resolve-tspaths:tests": "npm run resolve-tspaths -- --project packages/tests/tsconfig.json --src packages/tests/src --out packages/tests/dist", | ||
67 | "concurrently": "concurrently", | 76 | "concurrently": "concurrently", |
68 | "mocha": "mocha", | 77 | "mocha": "mocha", |
69 | "ci": "bash ./scripts/ci.sh", | 78 | "ci": "bash ./scripts/ci.sh", |
@@ -80,29 +89,30 @@ | |||
80 | "@aws-sdk/node-http-handler": "^3.190.0", | 89 | "@aws-sdk/node-http-handler": "^3.190.0", |
81 | "@aws-sdk/s3-request-presigner": "^3.345.0", | 90 | "@aws-sdk/s3-request-presigner": "^3.345.0", |
82 | "@babel/parser": "^7.17.8", | 91 | "@babel/parser": "^7.17.8", |
92 | "@commander-js/extra-typings": "^11.0.0", | ||
83 | "@node-oauth/oauth2-server": "^4.2.0", | 93 | "@node-oauth/oauth2-server": "^4.2.0", |
84 | "@opentelemetry/api": "^1.1.0", | 94 | "@opentelemetry/api": "^1.1.0", |
85 | "@opentelemetry/exporter-jaeger": "^1.3.1", | 95 | "@opentelemetry/exporter-jaeger": "^1.15.1", |
86 | "@opentelemetry/exporter-prometheus": "~0.39.1", | 96 | "@opentelemetry/exporter-prometheus": "~0.41.1", |
87 | "@opentelemetry/instrumentation": "^0.39.1", | 97 | "@opentelemetry/instrumentation": "^0.41.1", |
88 | "@opentelemetry/instrumentation-dns": "^0.31.2", | 98 | "@opentelemetry/instrumentation-dns": "^0.32.0", |
89 | "@opentelemetry/instrumentation-express": "^0.32.1", | 99 | "@opentelemetry/instrumentation-express": "^0.33.0", |
90 | "@opentelemetry/instrumentation-fs": "^0.7.0", | 100 | "@opentelemetry/instrumentation-fs": "^0.8.0", |
91 | "@opentelemetry/instrumentation-http": "^0.39.1", | 101 | "@opentelemetry/instrumentation-http": "^0.41.1", |
92 | "@opentelemetry/instrumentation-ioredis": "^0.34.2", | 102 | "@opentelemetry/instrumentation-ioredis": "^0.35.0", |
93 | "@opentelemetry/instrumentation-pg": "^0.35.2", | 103 | "@opentelemetry/instrumentation-pg": "^0.36.0", |
94 | "@opentelemetry/resources": "^1.3.1", | 104 | "@opentelemetry/resources": "^1.15.1", |
95 | "@opentelemetry/sdk-metrics": "^1.8.0", | 105 | "@opentelemetry/sdk-metrics": "^1.15.1", |
96 | "@opentelemetry/sdk-trace-base": "^1.3.1", | 106 | "@opentelemetry/sdk-trace-base": "^1.15.1", |
97 | "@opentelemetry/sdk-trace-node": "^1.3.1", | 107 | "@opentelemetry/sdk-trace-node": "^1.15.1", |
98 | "@opentelemetry/semantic-conventions": "^1.3.1", | 108 | "@opentelemetry/semantic-conventions": "^1.15.1", |
99 | "@peertube/feed": "^5.1.0", | 109 | "@peertube/feed": "^5.1.0", |
100 | "@peertube/http-signature": "^1.7.0", | 110 | "@peertube/http-signature": "^1.7.0", |
101 | "@uploadx/core": "^6.0.0", | 111 | "@uploadx/core": "^6.0.0", |
102 | "async-lru": "^1.1.1", | 112 | "async-lru": "^1.1.1", |
103 | "async-mutex": "^0.4.0", | 113 | "async-mutex": "^0.4.0", |
104 | "bcrypt": "5.1.0", | 114 | "bcrypt": "5.1.0", |
105 | "bencode": "^2.0.2", | 115 | "bencode": "^3.1.1", |
106 | "bittorrent-tracker": "^9", | 116 | "bittorrent-tracker": "^9", |
107 | "bluebird": "^3.5.0", | 117 | "bluebird": "^3.5.0", |
108 | "bullmq": "^3.6.6", | 118 | "bullmq": "^3.6.6", |
@@ -122,7 +132,7 @@ | |||
122 | "flat": "^5.0.0", | 132 | "flat": "^5.0.0", |
123 | "fluent-ffmpeg": "^2.1.0", | 133 | "fluent-ffmpeg": "^2.1.0", |
124 | "fs-extra": "^11.1.0", | 134 | "fs-extra": "^11.1.0", |
125 | "got": "^11.8.2", | 135 | "got": "^13.0.0", |
126 | "helmet": "^7.0.0", | 136 | "helmet": "^7.0.0", |
127 | "hpagent": "^1.0.0", | 137 | "hpagent": "^1.0.0", |
128 | "http-problem-details": "^0.1.5", | 138 | "http-problem-details": "^0.1.5", |
@@ -130,11 +140,11 @@ | |||
130 | "ip-anonymize": "^0.1.0", | 140 | "ip-anonymize": "^0.1.0", |
131 | "ipaddr.js": "2.0.1", | 141 | "ipaddr.js": "2.0.1", |
132 | "is-cidr": "^4.0.0", | 142 | "is-cidr": "^4.0.0", |
133 | "iso-639-3": "2.2.0", | 143 | "iso-639-3": "3.0.1", |
134 | "jimp": "^0.22.4", | 144 | "jimp": "^0.22.4", |
135 | "js-yaml": "^4.0.0", | 145 | "js-yaml": "^4.0.0", |
136 | "jsonld": "~8.2.0", | 146 | "jsonld": "~8.2.0", |
137 | "lodash": "^4.17.21", | 147 | "lodash-es": "^4.17.21", |
138 | "lru-cache": "^9.1.1", | 148 | "lru-cache": "^9.1.1", |
139 | "magnet-uri": "^6", | 149 | "magnet-uri": "^6", |
140 | "markdown-it": "^13.0.1", | 150 | "markdown-it": "^13.0.1", |
@@ -145,9 +155,9 @@ | |||
145 | "multer": "^1.4.5-lts.1", | 155 | "multer": "^1.4.5-lts.1", |
146 | "node-media-server": "^2.1.4", | 156 | "node-media-server": "^2.1.4", |
147 | "nodemailer": "^6.0.0", | 157 | "nodemailer": "^6.0.0", |
148 | "opentelemetry-instrumentation-sequelize": "^0.35.0", | 158 | "opentelemetry-instrumentation-sequelize": "^0.39.1", |
149 | "otpauth": "^9.0.2", | 159 | "otpauth": "^9.0.2", |
150 | "p-queue": "^6", | 160 | "p-queue": "^7.3.4", |
151 | "parse-torrent": "^9", | 161 | "parse-torrent": "^9", |
152 | "password-generator": "^2.0.2", | 162 | "password-generator": "^2.0.2", |
153 | "pg": "^8.2.1", | 163 | "pg": "^8.2.1", |
@@ -164,7 +174,6 @@ | |||
164 | "socket.io": "^4.5.4", | 174 | "socket.io": "^4.5.4", |
165 | "sql-formatter": "^12.0.1", | 175 | "sql-formatter": "^12.0.1", |
166 | "srt-to-vtt": "^1.1.2", | 176 | "srt-to-vtt": "^1.1.2", |
167 | "tsconfig-paths": "^4.0.0", | ||
168 | "tslib": "^2.0.0", | 177 | "tslib": "^2.0.0", |
169 | "useragent": "^2.3.0", | 178 | "useragent": "^2.3.0", |
170 | "validator": "^13.0.0", | 179 | "validator": "^13.0.0", |
@@ -175,6 +184,7 @@ | |||
175 | }, | 184 | }, |
176 | "devDependencies": { | 185 | "devDependencies": { |
177 | "@peertube/maildev": "^1.2.0", | 186 | "@peertube/maildev": "^1.2.0", |
187 | "@peertube/resolve-tspaths": "^0.8.14", | ||
178 | "@types/bcrypt": "^5.0.0", | 188 | "@types/bcrypt": "^5.0.0", |
179 | "@types/bencode": "^2.0.0", | 189 | "@types/bencode": "^2.0.0", |
180 | "@types/bluebird": "^3.5.33", | 190 | "@types/bluebird": "^3.5.33", |
@@ -188,7 +198,8 @@ | |||
188 | "@types/express": "4.17.9", | 198 | "@types/express": "4.17.9", |
189 | "@types/fluent-ffmpeg": "^2.1.16", | 199 | "@types/fluent-ffmpeg": "^2.1.16", |
190 | "@types/fs-extra": "^11.0.1", | 200 | "@types/fs-extra": "^11.0.1", |
191 | "@types/lodash": "^4.14.64", | 201 | "@types/jsonld": "^1.5.9", |
202 | "@types/lodash-es": "^4.17.8", | ||
192 | "@types/magnet-uri": "^5.1.1", | 203 | "@types/magnet-uri": "^5.1.1", |
193 | "@types/maildev": "^0.0.4", | 204 | "@types/maildev": "^0.0.4", |
194 | "@types/memoizee": "^0.4.2", | 205 | "@types/memoizee": "^0.4.2", |
@@ -200,7 +211,7 @@ | |||
200 | "@types/oauth2-server": "^3.0.8", | 211 | "@types/oauth2-server": "^3.0.8", |
201 | "@types/request": "^2.0.3", | 212 | "@types/request": "^2.0.3", |
202 | "@types/supertest": "^2.0.3", | 213 | "@types/supertest": "^2.0.3", |
203 | "@types/validator": "^13.0.0", | 214 | "@types/validator": "^13.9.0", |
204 | "@types/webtorrent": "^0.109.0", | 215 | "@types/webtorrent": "^0.109.0", |
205 | "@types/ws": "^8.2.0", | 216 | "@types/ws": "^8.2.0", |
206 | "@typescript-eslint/eslint-plugin": "^5.0.0", | 217 | "@typescript-eslint/eslint-plugin": "^5.0.0", |
@@ -210,6 +221,7 @@ | |||
210 | "chai-xml": "^0.4.0", | 221 | "chai-xml": "^0.4.0", |
211 | "concurrently": "^8.0.1", | 222 | "concurrently": "^8.0.1", |
212 | "depcheck": "^1.4.2", | 223 | "depcheck": "^1.4.2", |
224 | "esbuild": "^0.19.0", | ||
213 | "eslint": "8.41.0", | 225 | "eslint": "8.41.0", |
214 | "eslint-config-standard-with-typescript": "34.0.1", | 226 | "eslint-config-standard-with-typescript": "34.0.1", |
215 | "eslint-plugin-import": "^2.20.1", | 227 | "eslint-plugin-import": "^2.20.1", |
@@ -222,12 +234,11 @@ | |||
222 | "pixelmatch": "^5.3.0", | 234 | "pixelmatch": "^5.3.0", |
223 | "pngjs": "^7.0.0", | 235 | "pngjs": "^7.0.0", |
224 | "proxy": "^2.1.1", | 236 | "proxy": "^2.1.1", |
225 | "resolve-tspaths": "^0.8.8", | ||
226 | "socket.io-client": "^4.5.4", | 237 | "socket.io-client": "^4.5.4", |
227 | "supertest": "^6.0.1", | 238 | "supertest": "^6.0.1", |
228 | "swagger-cli": "^4.0.2", | 239 | "swagger-cli": "^4.0.2", |
229 | "ts-node": "^10.8.1", | ||
230 | "tsc-watch": "^6.0.0", | 240 | "tsc-watch": "^6.0.0", |
241 | "tsx": "^3.12.7", | ||
231 | "typescript": "~5.0.4" | 242 | "typescript": "~5.0.4" |
232 | }, | 243 | }, |
233 | "bundlewatch": { | 244 | "bundlewatch": { |