diff --git a/package.json b/package.json index f17da34d0..17cb6677d 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,6 @@ "lru-cache": "^5.1.1", "magnet-uri": "^5.1.4", "memoizee": "^0.4.14", - "module-alias": "^2.2.1", "morgan": "^1.5.3", "multer": "^1.1.0", "nodemailer": "^6.0.0", @@ -152,6 +151,7 @@ "sitemap": "^5.0.0", "socket.io": "^2.2.0", "srt-to-vtt": "^1.1.2", + "tsconfig-paths": "^3.9.0", "useragent": "^2.3.0", "uuid": "^3.1.0", "validator": "^11.0.0", diff --git a/scripts/build/server.sh b/scripts/build/server.sh index 3880ac5fa..d66a52475 100755 --- a/scripts/build/server.sh +++ b/scripts/build/server.sh @@ -5,4 +5,5 @@ set -eu rm -rf ./dist npm run tsc +cp "./tsconfig.json" "./dist" cp -r "./server/static" "./server/assets" "./dist/server" diff --git a/server.ts b/server.ts index 5cfa09445..b49d10344 100644 --- a/server.ts +++ b/server.ts @@ -1,12 +1,18 @@ -require('module-alias/register') +import { resolve } from 'path' + +const tsConfig = require('./tsconfig.json') +const tsConfigPaths = require('tsconfig-paths') + +// Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883 +tsConfigPaths.register({ + baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''), + paths: tsConfig.compilerOptions.paths +}) // FIXME: https://github.com/nodejs/node/pull/16853 -import { PluginManager } from './server/lib/plugins/plugin-manager' - require('tls').DEFAULT_ECDH_CURVE = 'auto' import { isTestInstance } from './server/helpers/core-utils' - if (isTestInstance()) { require('source-map-support').install() } @@ -121,6 +127,7 @@ import { PeerTubeSocket } from './server/lib/peertube-socket' import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls' import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' import { Hooks } from './server/lib/plugins/hooks' +import { PluginManager } from './server/lib/plugins/plugin-manager' // ----------- Command line ----------- diff --git a/server/tests/helpers/core-utils.ts b/server/tests/helpers/core-utils.ts index e604cf7e3..2dbe8d635 100644 --- a/server/tests/helpers/core-utils.ts +++ b/server/tests/helpers/core-utils.ts @@ -2,10 +2,8 @@ import * as chai from 'chai' import 'mocha' -import { snakeCase, isNumber } from 'lodash' -import { - parseBytes, objectConverter -} from '../../helpers/core-utils' +import { snakeCase } from 'lodash' +import { objectConverter, parseBytes } from '../../helpers/core-utils' import { isNumeric } from 'validator' const expect = chai.expect diff --git a/yarn.lock b/yarn.lock index eafeffad3..b6a59b855 100644 --- a/yarn.lock +++ b/yarn.lock @@ -206,6 +206,11 @@ dependencies: "@types/node" "*" +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= + "@types/libxmljs@^0.18.0": version "0.18.3" resolved "https://registry.yarnpkg.com/@types/libxmljs/-/libxmljs-0.18.3.tgz#5aaed8fc4ec5ea99e005ee5dfb47cf9924166a4d" @@ -4551,11 +4556,6 @@ mocha@^6.0.0: yargs-parser "13.1.1" yargs-unparser "1.6.0" -module-alias@^2.2.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0" - integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q== - moment-timezone@^0.5.21, moment-timezone@^0.5.25: version "0.5.27" resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.27.tgz#73adec8139b6fe30452e78f210f27b1f346b8877" @@ -6752,6 +6752,11 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" @@ -7097,6 +7102,16 @@ ts-node@8.4.1: source-map-support "^0.5.6" yn "^3.0.0" +tsconfig-paths@^3.9.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b" + integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.1" + minimist "^1.2.0" + strip-bom "^3.0.0" + tslib@1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"