🎨 use typescript plugin that converts to relative paths

This commit is contained in:
Flam3rboy 2021-09-18 01:50:20 +02:00
parent 69550e535e
commit 1e331b7c9d
16 changed files with 35 additions and 52 deletions

6
api/babel.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
["@babel/preset-typescript", { allowDeclareFields: true }]
]
};

BIN
api/package-lock.json generated

Binary file not shown.

View File

@ -5,16 +5,18 @@
"main": "dist/Server.js", "main": "dist/Server.js",
"types": "dist/Server.d.ts", "types": "dist/Server.d.ts",
"scripts": { "scripts": {
"test:only": "node -r ./scripts/tsconfig-paths-bootstrap.js node_modules/.bin/jest --coverage --verbose --forceExit ./tests", "prepare": "ts-patch install -s",
"test:only": "jest --coverage --verbose --forceExit ./tests",
"test": "npm run build && npm run test:only", "test": "npm run build && npm run test:only",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start", "start": "npm run build && node dist/start",
"build": "npx tsc -b .", "build": "npx tsc -b .",
"build-docker": "tsc -p tsconfig-docker.json", "build-docker": "tsc -p tsconfig-docker.json",
"dev": "tsnd --respawn src/start.ts", "dev": "tsnd --respawn src/start.ts",
"patch": "npx patch-package", "patch": "npx patch-package",
"postinstall": "npm run patch", "postinstall": "npm run patch",
"generate:docs": "ts-node scripts/generate_openapi_schema.ts", "generate:docs": "ts-node scripts/generate_openapi_schema.ts",
"generate:test": "ts-node scripts/generate_test_schema.ts",
"generate:schema": "ts-node scripts/generate_body_schema.ts" "generate:schema": "ts-node scripts/generate_body_schema.ts"
}, },
"repository": { "repository": {
@ -36,6 +38,9 @@
}, },
"homepage": "https://fosscord.com", "homepage": "https://fosscord.com",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"@types/amqplib": "^0.8.1", "@types/amqplib": "^0.8.1",
"@types/bcrypt": "^5.0.0", "@types/bcrypt": "^5.0.0",
"@types/express": "^4.17.9", "@types/express": "^4.17.9",
@ -49,14 +54,17 @@
"@types/multer": "^1.4.5", "@types/multer": "^1.4.5",
"@types/node": "^14.17.9", "@types/node": "^14.17.9",
"@types/node-fetch": "^2.5.7", "@types/node-fetch": "^2.5.7",
"@types/supertest": "^2.0.11",
"@zerollup/ts-transform-paths": "^1.7.18", "@zerollup/ts-transform-paths": "^1.7.18",
"0x": "^4.10.2", "0x": "^4.10.2",
"babel-jest": "^27.2.0",
"caxa": "^2.1.0", "caxa": "^2.1.0",
"image-size": "^1.0.0", "image-size": "^1.0.0",
"jest": "^26.6.3", "jest": "^26.6.3",
"saslprep": "^1.0.3", "saslprep": "^1.0.3",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"ts-node-dev": "^1.1.6", "ts-node-dev": "^1.1.6",
"ts-patch": "^1.4.4",
"typescript": "^4.4.2", "typescript": "^4.4.2",
"typescript-json-schema": "0.50.1" "typescript-json-schema": "0.50.1"
}, },
@ -96,7 +104,7 @@
"setupFiles": [ "setupFiles": [
"<rootDir>/jest/setup.js" "<rootDir>/jest/setup.js"
], ],
"globalSetup": "<rootDir>/scripts/globalSetup.js", "globalSetup": "<rootDir>/jest/globalSetup.js",
"verbose": true "verbose": true
} }
} }

View File

@ -66,8 +66,9 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@fosscord/api": ["src/index.ts"], "@fosscord/api": ["src/index"],
"@fosscord/api/*": ["src/*"] "@fosscord/api/*": ["src/*"]
} },
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
} }
} }

BIN
bundle/package-lock.json generated

Binary file not shown.

View File

@ -4,6 +4,7 @@
"description": "", "description": "",
"main": "src/start.js", "main": "src/start.js",
"scripts": { "scripts": {
"prepare": "ts-patch install -s",
"preinstall": "cd ../util && npm i && cd ../api && npm i && cd ../cdn && npm i && cd ../gateway && npm i", "preinstall": "cd ../util && npm i && cd ../api && npm i && cd ../cdn && npm i && cd ../gateway && npm i",
"build": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle", "build": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle",
"build:bundle": "npx tsc -b .", "build:bundle": "npx tsc -b .",
@ -12,7 +13,7 @@
"build:cdn": "cd ../cdn/ && npm run build", "build:cdn": "cd ../cdn/ && npm run build",
"build:gateway": "cd ../gateway/ && npm run build", "build:gateway": "cd ../gateway/ && npm run build",
"start": "npm run build && npm run start:bundle", "start": "npm run build && npm run start:bundle",
"start:bundle": "node -r ./tsconfig-paths-bootstrap.js dist/start.js", "start:bundle": "node dist/start.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
@ -43,6 +44,7 @@
"@types/uuid": "^8.3.0", "@types/uuid": "^8.3.0",
"@types/ws": "^7.4.0", "@types/ws": "^7.4.0",
"@zerollup/ts-transform-paths": "^1.7.18", "@zerollup/ts-transform-paths": "^1.7.18",
"ts-patch": "^1.4.4",
"typescript": "^4.3.5" "typescript": "^4.3.5"
}, },
"dependencies": { "dependencies": {

View File

@ -1,14 +0,0 @@
const tsConfigPaths = require("tsconfig-paths");
const path = require("path");
const cleanup = tsConfigPaths.register({
baseUrl: path.join(__dirname, "node_modules", "@fosscord"),
paths: {
"@fosscord/api": ["api/dist/index.js"],
"@fosscord/api/*": ["api/dist/*"],
"@fosscord/gateway": ["gateway/dist/index.js"],
"@fosscord/gateway/*": ["gateway/dist/*"],
"@fosscord/cdn": ["cdn/dist/index.js"],
"@fosscord/cdn/*": ["cdn/dist/*"],
},
});

BIN
cdn/package-lock.json generated

Binary file not shown.

View File

@ -5,9 +5,10 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"prepare": "ts-patch install -s",
"test": "npm run build && jest --coverage ./tests", "test": "npm run build && jest --coverage ./tests",
"build": "npx tsc -b .", "build": "npx tsc -b .",
"start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start.js" "start": "npm run build && node dist/start.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -34,7 +35,8 @@
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^14.17.0", "@types/node": "^14.17.0",
"@types/node-fetch": "^2.5.7", "@types/node-fetch": "^2.5.7",
"@types/uuid": "^8.3.0" "@types/uuid": "^8.3.0",
"ts-patch": "^1.4.4"
}, },
"dependencies": { "dependencies": {
"@fosscord/util": "file:../util", "@fosscord/util": "file:../util",

View File

@ -1,10 +0,0 @@
const tsConfigPaths = require("tsconfig-paths");
const path = require("path");
const cleanup = tsConfigPaths.register({
baseUrl: path.join(__dirname, ".."),
paths: {
"@fosscord/cdn": ["dist/index.js"],
"@fosscord/cdn/*": ["dist/*"],
},
});

View File

@ -70,6 +70,7 @@
"paths": { "paths": {
"@fosscord/cdn/": ["src/index.ts"], "@fosscord/cdn/": ["src/index.ts"],
"@fosscord/cdn/*": ["src/*"] "@fosscord/cdn/*": ["src/*"]
} },
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
} }
} }

Binary file not shown.

View File

@ -4,8 +4,9 @@
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"prepare": "ts-patch install -s",
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start.js", "start": "npm run build && node dist/start.js",
"build": "npx tsc -b .", "build": "npx tsc -b .",
"dev": "tsnd --respawn src/start.ts" "dev": "tsnd --respawn src/start.ts"
}, },
@ -23,6 +24,7 @@
"@types/uuid": "^8.3.0", "@types/uuid": "^8.3.0",
"@types/ws": "^7.4.0", "@types/ws": "^7.4.0",
"ts-node-dev": "^1.1.6", "ts-node-dev": "^1.1.6",
"ts-patch": "^1.4.4",
"typescript": "^4.2.3" "typescript": "^4.2.3"
}, },
"dependencies": { "dependencies": {

View File

@ -1,10 +0,0 @@
const tsConfigPaths = require("tsconfig-paths");
const path = require("path");
const cleanup = tsConfigPaths.register({
baseUrl: path.join(__dirname, ".."),
paths: {
"@fosscord/gateway": ["dist/index.js"],
"@fosscord/gateway/*": ["dist/*"],
},
});

View File

@ -72,6 +72,7 @@
"paths": { "paths": {
"@fosscord/gateway/*": ["src/*"], "@fosscord/gateway/*": ["src/*"],
"@fosscord/util/*": ["../util/src/*"] "@fosscord/util/*": ["../util/src/*"]
} },
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
} }
} }

View File

@ -68,12 +68,6 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"resolveJsonModule": true, "resolveJsonModule": true
"plugins": [
{
"transform": "ts-transform-json-schema",
"type": "program"
}
]
} }
} }