Reduce peertube types package size

pull/6562/head
Chocobozzz 2024-08-12 09:37:24 +02:00
parent fbabfde819
commit 90859f2b61
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
13 changed files with 176 additions and 31 deletions

View File

@ -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": [

View File

@ -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",

View File

@ -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": true

View File

@ -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": true

View File

@ -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#api
const 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 })

View File

@ -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 config

View File

@ -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/*" ]
}

View File

@ -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
}

View File

@ -5,7 +5,7 @@
"node_modules/@types",
"client/node_modules/@types"
],
"baseUrl": "./dist",
"baseUrl": "./dist-tmp",
"paths": {
"@server/*": [ "server/core/*" ],
"@client/*": [ "client/*" ],

View File

@ -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/*" ]
}

View File

@ -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": true

View File

@ -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/"
]
}

121
yarn.lock
View File

@ -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/rollup-android-arm-eabi@4.20.0":
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/rollup-android-arm64@4.20.0":
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/rollup-darwin-arm64@4.20.0":
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/rollup-darwin-x64@4.20.0":
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/rollup-linux-arm-gnueabihf@4.20.0":
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/rollup-linux-arm-musleabihf@4.20.0":
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/rollup-linux-arm64-gnu@4.20.0":
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/rollup-linux-arm64-musl@4.20.0":
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/rollup-linux-powerpc64le-gnu@4.20.0":
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/rollup-linux-riscv64-gnu@4.20.0":
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/rollup-linux-s390x-gnu@4.20.0":
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/rollup-linux-x64-gnu@4.20.0":
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/rollup-linux-x64-musl@4.20.0":
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/rollup-win32-arm64-msvc@4.20.0":
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/rollup-win32-ia32-msvc@4.20.0":
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/rollup-win32-x64-msvc@4.20.0":
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/estree@1.0.5":
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"