ActivityPub-federated video streaming platform using P2P directly in your web browser
Reduce peertube types package size
Chocobozzz90859f2b6177
diff --git a/client/tsconfig.types.json b/client/tsconfig.types.jsonindex 1481bc9b9e..417db34538 100644--- a/client/tsconfig.types.json+++ b/client/tsconfig.types.json@@ -4,11 +4,11 @@"stripInternal": true,"removeComments": false,"declaration": true,- "outDir": "../packages/types-generator/dist/client/",+ "outDir": "../packages/types-generator/dist-tmp/client/","emitDeclarationOnly": true,"composite": true,"rootDir": "src/",- "tsBuildInfoFile": "../packages/types-generator/dist/tsconfig.client.tsbuildinfo"+ "tsBuildInfoFile": "../packages/types-generator/dist-tmp/tsconfig.client.tsbuildinfo"},"files": [ "src/types/index.ts" ],"include": [diff --git a/package.json b/package.jsonindex 4db5d24f8e..c3a09d770a 100644--- a/package.json+++ b/package.json@@ -241,6 +241,8 @@"pixelmatch": "^5.3.0","pngjs": "^7.0.0","proxy": "^2.1.1",+ "rollup": "^4.20.0",+ "rollup-plugin-dts": "^6.1.1","socket.io-client": "^4.5.4","supertest": "^7.0.0","swagger-cli": "^4.0.2",diff --git a/packages/models/tsconfig.types.json b/packages/models/tsconfig.types.jsonindex 997161c21f..2e8d6b17dc 100644--- a/packages/models/tsconfig.types.json+++ b/packages/models/tsconfig.types.json@@ -1,8 +1,8 @@{"extends": "./tsconfig.json","compilerOptions": {- "outDir": "../types-generator/dist/peertube-models",- "tsBuildInfoFile": "../types-generator/dist/peertube-models/.tsbuildinfo",+ "outDir": "../types-generator/dist-tmp/peertube-models",+ "tsBuildInfoFile": "../types-generator/dist-tmp/peertube-models/.tsbuildinfo","stripInternal": true,"removeComments": false,"emitDeclarationOnly": truediff --git a/packages/transcription/tsconfig.types.json b/packages/transcription/tsconfig.types.jsonindex 9edb53ece0..135bcae900 100644--- a/packages/transcription/tsconfig.types.json+++ b/packages/transcription/tsconfig.types.json@@ -1,8 +1,8 @@{"extends": "./tsconfig.json","compilerOptions": {- "outDir": "../types-generator/dist/peertube-transcription",- "tsBuildInfoFile": "../types-generator/dist/peertube-transcription/.tsbuildinfo",+ "outDir": "../types-generator/dist-tmp/peertube-transcription",+ "tsBuildInfoFile": "../types-generator/dist-tmp/peertube-transcription/.tsbuildinfo","stripInternal": true,"removeComments": false,"emitDeclarationOnly": truediff --git a/packages/types-generator/generate-package.ts b/packages/types-generator/generate-package.tsindex 358ea142ba..26b224d176 100644--- a/packages/types-generator/generate-package.ts+++ b/packages/types-generator/generate-package.ts@@ -1,9 +1,9 @@+import { currentDir, root } from '@peertube/peertube-node-utils'import { execSync } from 'child_process'import depcheck, { PackageDependencies } from 'depcheck'import { readJson, remove, writeJSON } from 'fs-extra/esm'import { copyFile, writeFile } from 'fs/promises'import { join, resolve } from 'path'-import { currentDir, root } from '@peertube/peertube-node-utils'if (!process.argv[2]) {console.error('Need version as argument')@@ -22,25 +22,30 @@ run()async function run () {const typesPath = currentDir(import.meta.url)- const typesDistPath = join(typesPath, 'dist')+ const typesDistTMPPath = join(typesPath, 'dist-tmp')- await remove(typesDistPath)-- const typesDistPackageJsonPath = join(typesDistPath, 'package.json')- const typesDistGitIgnorePath = join(typesDistPath, '.gitignore')+ await remove(typesDistTMPPath)const mainPackageJson = await readJson(join(root(), 'package.json'))const typesTsConfigPath = join(typesPath, 'tsconfig.types.json')- const distTsConfigPath = join(typesPath, 'tsconfig.dist.json')- const distTsConfig = await readJson(distTsConfigPath)+ const distTmpTsConfigPath = join(typesPath, 'tsconfig.dist-tmp.json')+ const distTmpTsConfig = await readJson(distTmpTsConfigPath)const clientPackageJson = await readJson(join(root(), 'client', 'package.json'))- await remove(typesDistPath)+ const typesDistPath = join(typesPath, 'dist')+ const rollupConfig = join(typesPath, 'rollup.config.js')++ await remove(typesDistTMPPath)+execSync(`npm run tsc -- -b ${typesTsConfigPath} --verbose`, { stdio: 'inherit' })- execSync(`npm run resolve-tspaths -- --project ${distTsConfigPath} --src ${typesDistPath} --out ${typesDistPath}`, { stdio: 'inherit' })+ // eslint-disable-next-line max-len+ execSync(`npm run resolve-tspaths -- --project ${distTmpTsConfigPath} --src ${typesDistTMPPath} --out ${typesDistTMPPath}`, { stdio: 'inherit' })++ execSync(`./node_modules/.bin/rollup -c ${rollupConfig}`, { stdio: 'inherit' })+ await remove(typesDistTMPPath)const allDependencies = Object.assign(mainPackageJson.dependencies,@@ -49,7 +54,7 @@ async function run () {clientPackageJson.devDependencies) as PackageDependencies- const toIgnore = Object.keys(distTsConfig?.compilerOptions?.paths || [])+ const toIgnore = Object.keys(distTmpTsConfig?.compilerOptions?.paths || [])// https://github.com/depcheck/depcheck#apiconst depcheckOptions = {@@ -98,6 +103,10 @@ async function run () {repository,dependencies}++ const typesDistPackageJsonPath = join(typesDistPath, 'package.json')+ const typesDistGitIgnorePath = join(typesDistPath, '.gitignore')+console.log(`Writing package.json to ${typesDistPackageJsonPath}`)await writeJSON(typesDistPackageJsonPath, typesPackageJson, { spaces: 2 })diff --git a/packages/types-generator/rollup.config.js b/packages/types-generator/rollup.config.jsnew file mode 100644index 0000000000..35855bfe3c--- /dev/null+++ b/packages/types-generator/rollup.config.js@@ -0,0 +1,16 @@+import { dts } from 'rollup-plugin-dts'++const config = [+ {+ input: './packages/types-generator/dist-tmp/index.d.ts',+ output: [ { file: './packages/types-generator/dist/index.d.ts', format: 'es' } ],+ plugins: [ dts({ tsconfig: './packages/types-generator/tsconfig.dist-tmp.json' }) ],+ },+ {+ input: './packages/types-generator/dist-tmp/client/index.d.ts',+ output: [ { file: './packages/types-generator/dist/client/index.d.ts', format: 'es' } ],+ plugins: [ dts({ tsconfig: './packages/types-generator/tsconfig.dist-tmp.json' }) ],+ }+]++export default configdiff --git a/packages/types-generator/src/client/tsconfig.types.json b/packages/types-generator/src/client/tsconfig.types.jsonindex f60b43f07a..a1203c0bed 100644--- a/packages/types-generator/src/client/tsconfig.types.json+++ b/packages/types-generator/src/client/tsconfig.types.json@@ -4,10 +4,10 @@"stripInternal": true,"removeComments": false,"emitDeclarationOnly": true,- "outDir": "../../dist/client/",+ "outDir": "../../dist-tmp/client/","rootDir": "./","baseUrl": "./",- "tsBuildInfoFile": "../../dist/tsconfig.client.types.tsbuildinfo",+ "tsBuildInfoFile": "../../dist-tmp/tsconfig.client.types.tsbuildinfo","paths": {"@client/*": [ "../../../../client/src/*" ]}diff --git a/packages/types-generator/tests/test.ts b/packages/types-generator/tests/test.tsindex bfdcdeed5b..8d23e7a1af 100644--- a/packages/types-generator/tests/test.ts+++ b/packages/types-generator/tests/test.ts@@ -1,4 +1,4 @@-import { RegisterServerOptions, Video } from '../dist/index.js'+import { RegisterServerOptions, Video, MVideo } from '../dist/index.js'import { RegisterClientOptions } from '../dist/client/index.js'function register1 ({ registerHook }: RegisterServerOptions) {@@ -12,6 +12,8 @@ function register2 ({ registerHook, peertubeHelpers }: RegisterClientOptions) {registerHook({target: 'action:admin-plugin-settings.init',handler: ({ npmName }: { npmName: string }) => {+ let video: MVideo+if ('peertube-plugin-transcription' !== npmName) {return}diff --git a/packages/types-generator/tsconfig.dist.json b/packages/types-generator/tsconfig.dist-tmp.jsonsimilarity index 92%rename from packages/types-generator/tsconfig.dist.jsonrename to packages/types-generator/tsconfig.dist-tmp.jsonindex e13bcde157..908a31d048 100644--- a/packages/types-generator/tsconfig.dist.json+++ b/packages/types-generator/tsconfig.dist-tmp.json@@ -5,7 +5,7 @@"node_modules/@types","client/node_modules/@types"],- "baseUrl": "./dist",+ "baseUrl": "./dist-tmp","paths": {"@server/*": [ "server/core/*" ],"@client/*": [ "client/*" ],diff --git a/packages/types-generator/tsconfig.types.json b/packages/types-generator/tsconfig.types.jsonindex dd23a61d25..160d86bbe5 100644--- a/packages/types-generator/tsconfig.types.json+++ b/packages/types-generator/tsconfig.types.json@@ -5,10 +5,10 @@"removeComments": false,"emitDeclarationOnly": true,"sourceMap": false,- "outDir": "./dist/",+ "outDir": "./dist-tmp/","baseUrl": "./","rootDir": "./src",- "tsBuildInfoFile": "./dist/tsconfig.server.types.tsbuildinfo",+ "tsBuildInfoFile": "./dist-tmp/tsconfig.server.types.tsbuildinfo","paths": {"@server/*": [ "../../server/core/*" ]}diff --git a/packages/typescript-utils/tsconfig.types.json b/packages/typescript-utils/tsconfig.types.jsonindex e666b4ca26..69d1114bc4 100644--- a/packages/typescript-utils/tsconfig.types.json+++ b/packages/typescript-utils/tsconfig.types.json@@ -1,8 +1,8 @@{"extends": "./tsconfig.json","compilerOptions": {- "outDir": "../types-generator/dist/peertube-typescript-utils",- "tsBuildInfoFile": "../types-generator/dist/peertube-typescript-utils/.tsbuildinfo",+ "outDir": "../types-generator/dist-tmp/peertube-typescript-utils",+ "tsBuildInfoFile": "../types-generator/dist-tmp/peertube-typescript-utils/.tsbuildinfo","stripInternal": true,"removeComments": false,"emitDeclarationOnly": truediff --git a/server/tsconfig.types.json b/server/tsconfig.types.jsonindex 444f9b0a13..755de207bd 100644--- a/server/tsconfig.types.json+++ b/server/tsconfig.types.json@@ -1,8 +1,8 @@{"extends": "./tsconfig.json","compilerOptions": {- "outDir": "../packages/types-generator/dist/server",- "tsBuildInfoFile": "../packages/types-generator/dist/server/.tsbuildinfo",+ "outDir": "../packages/types-generator/dist-tmp/server",+ "tsBuildInfoFile": "../packages/types-generator/dist-tmp/server/.tsbuildinfo","stripInternal": true,"removeComments": false,"emitDeclarationOnly": true@@ -15,8 +15,5 @@{ "path": "../packages/server-commands" },{ "path": "../packages/typescript-utils" },{ "path": "../packages/transcription" }- ],- "exclude": [- "tests/"]}diff --git a/yarn.lock b/yarn.lockindex aec5169708..b810f9a2e2 100644--- a/yarn.lock+++ b/yarn.lock@@ -679,7 +679,7 @@"@smithy/types" "^3.1.0"tslib "^2.6.2"-"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.24.7":+"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.24.2", "@babel/code-frame@^7.24.7":version "7.24.7"resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.24.7.tgz#882fd9e09e8ee324e496bd040401c6f046ef4465"integrity sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==@@ -1735,6 +1735,86 @@resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==+"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.20.0.tgz#c3f5660f67030c493a981ac1d34ee9dfe1d8ec0f"+ integrity sha512-TSpWzflCc4VGAUJZlPpgAJE1+V60MePDQnBd7PPkpuEmOy8i87aL6tinFGKBFKuEDikYpig72QzdT3QPYIi+oA==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.20.0.tgz#64161f0b67050023a3859e723570af54a82cff5c"+ integrity sha512-u00Ro/nok7oGzVuh/FMYfNoGqxU5CPWz1mxV85S2w9LxHR8OoMQBuSk+3BKVIDYgkpeOET5yXkx90OYFc+ytpQ==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.20.0.tgz#25f3d57b1da433097cfebc89341b355901615763"+ integrity sha512-uFVfvzvsdGtlSLuL0ZlvPJvl6ZmrH4CBwLGEFPe7hUmf7htGAN+aXo43R/V6LATyxlKVC/m6UsLb7jbG+LG39Q==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.20.0.tgz#d8ddaffb636cc2f59222c50316e27771e48966df"+ integrity sha512-xbrMDdlev53vNXexEa6l0LffojxhqDTBeL+VUxuuIXys4x6xyvbKq5XqTXBCEUA8ty8iEJblHvFaWRJTk/icAQ==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.20.0.tgz#41bd4fcffa20fb84f3dbac6c5071638f46151885"+ integrity sha512-jMYvxZwGmoHFBTbr12Xc6wOdc2xA5tF5F2q6t7Rcfab68TT0n+r7dgawD4qhPEvasDsVpQi+MgDzj2faOLsZjA==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.20.0.tgz#842077c5113a747eb5686f19f2f18c33ecc0acc8"+ integrity sha512-1asSTl4HKuIHIB1GcdFHNNZhxAYEdqML/MW4QmPS4G0ivbEcBr1JKlFLKsIRqjSwOBkdItn3/ZDlyvZ/N6KPlw==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.20.0.tgz#65d1d5b6778848f55b7823958044bf3e8737e5b7"+ integrity sha512-COBb8Bkx56KldOYJfMf6wKeYJrtJ9vEgBRAOkfw6Ens0tnmzPqvlpjZiLgkhg6cA3DGzCmLmmd319pmHvKWWlQ==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.20.0.tgz#50eef7d6e24d0fe3332200bb666cad2be8afcf86"+ integrity sha512-+it+mBSyMslVQa8wSPvBx53fYuZK/oLTu5RJoXogjk6x7Q7sz1GNRsXWjn6SwyJm8E/oMjNVwPhmNdIjwP135Q==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.20.0.tgz#8837e858f53c84607f05ad0602943e96d104c6b4"+ integrity sha512-yAMvqhPfGKsAxHN8I4+jE0CpLWD8cv4z7CK7BMmhjDuz606Q2tFKkWRY8bHR9JQXYcoLfopo5TTqzxgPUjUMfw==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.20.0.tgz#c894ade2300caa447757ddf45787cca246e816a4"+ integrity sha512-qmuxFpfmi/2SUkAw95TtNq/w/I7Gpjurx609OOOV7U4vhvUhBcftcmXwl3rqAek+ADBwSjIC4IVNLiszoj3dPA==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.20.0.tgz#5841e5390d4c82dd5cdf7b2c95a830e3c2f47dd3"+ integrity sha512-I0BtGXddHSHjV1mqTNkgUZLnS3WtsqebAXv11D5BZE/gfw5KoyXSAXVqyJximQXNvNzUo4GKlCK/dIwXlz+jlg==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.20.0.tgz#cc1f26398bf777807a99226dc13f47eb0f6c720d"+ integrity sha512-y+eoL2I3iphUg9tN9GB6ku1FA8kOfmF4oUEWhztDJ4KXJy1agk/9+pejOuZkNFhRwHAOxMsBPLbXPd6mJiCwew==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.20.0.tgz#1507465d9056e0502a590d4c1a00b4d7b1fda370"+ integrity sha512-hM3nhW40kBNYUkZb/r9k2FKK+/MnKglX7UYd4ZUy5DJs8/sMsIbqWK2piZtVGE3kcXVNj3B2IrUYROJMMCikNg==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.20.0.tgz#86a221f01a2c248104dd0defb4da119f2a73642e"+ integrity sha512-psegMvP+Ik/Bg7QRJbv8w8PAytPA7Uo8fpFjXyCRHWm6Nt42L+JtoqH8eDQ5hRP7/XW2UiIriy1Z46jf0Oa1kA==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.20.0.tgz#8bc8f77e02760aa664694b4286d6fbea7f1331c5"+ integrity sha512-GabekH3w4lgAJpVxkk7hUzUf2hICSQO0a/BLFA11/RMxQT92MabKAqyubzDZmMOC/hcJNlc+rrypzNzYl4Dx7A==++"@rollup/[email protected]":+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.20.0.tgz#601fffee719a1e8447f908aca97864eec23b2784"+ integrity sha512-aJ1EJSuTdGnM6qbVC4B5DSmozPTqIag9fSzXRNNo+humQLG89XpPgdt16Ia56ORD7s+H8Pmyx44uczDQ0yDzpg==+"@sec-ant/readable-stream@^0.4.1":version "0.4.1"resolved "https://registry.yarnpkg.com/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz#60de891bb126abfdc5410fdc6166aca065f10a0c"@@ -2421,6 +2501,11 @@dependencies:"@types/ms" "*"+"@types/[email protected]":+ version "1.0.5"+ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"+ integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==+"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33":version "4.19.5"resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.19.5.tgz#218064e321126fcf9048d1ca25dd2465da55d9c6"@@ -9244,6 +9329,40 @@ rimraf@^3.0.2:dependencies:glob "^7.1.3"+rollup-plugin-dts@^6.1.1:+ version "6.1.1"+ resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz#46b33f4d1d7f4e66f1171ced9b282ac11a15a254"+ integrity sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA==+ dependencies:+ magic-string "^0.30.10"+ optionalDependencies:+ "@babel/code-frame" "^7.24.2"++rollup@^4.20.0:+ version "4.20.0"+ resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.20.0.tgz#f9d602161d29e178f0bf1d9f35f0a26f83939492"+ integrity sha512-6rbWBChcnSGzIlXeIdNIZTopKYad8ZG8ajhl78lGRLsI2rX8IkaotQhVas2Ma+GPxJav19wrSzvRvuiv0YKzWw==+ dependencies:+ "@types/estree" "1.0.5"+ optionalDependencies:+ "@rollup/rollup-android-arm-eabi" "4.20.0"+ "@rollup/rollup-android-arm64" "4.20.0"+ "@rollup/rollup-darwin-arm64" "4.20.0"+ "@rollup/rollup-darwin-x64" "4.20.0"+ "@rollup/rollup-linux-arm-gnueabihf" "4.20.0"+ "@rollup/rollup-linux-arm-musleabihf" "4.20.0"+ "@rollup/rollup-linux-arm64-gnu" "4.20.0"+ "@rollup/rollup-linux-arm64-musl" "4.20.0"+ "@rollup/rollup-linux-powerpc64le-gnu" "4.20.0"+ "@rollup/rollup-linux-riscv64-gnu" "4.20.0"+ "@rollup/rollup-linux-s390x-gnu" "4.20.0"+ "@rollup/rollup-linux-x64-gnu" "4.20.0"+ "@rollup/rollup-linux-x64-musl" "4.20.0"+ "@rollup/rollup-win32-arm64-msvc" "4.20.0"+ "@rollup/rollup-win32-ia32-msvc" "4.20.0"+ "@rollup/rollup-win32-x64-msvc" "4.20.0"+ fsevents "~2.3.2"+run-applescript@^3.0.0:version "3.2.0"resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-3.2.0.tgz#73fb34ce85d3de8076d511ea767c30d4fdfc918b"