From d0ac509b74327ccaa453aea5596549c6527bf8c0 Mon Sep 17 00:00:00 2001 From: barthofu Date: Mon, 4 Dec 2023 16:08:31 +0000 Subject: [PATCH] feat(#132): switching from `swc` to `tsc` `swc`, despite being a little faster, was involving way too much random issues and wasn't stable at all. --- .docker/app/Dockerfile | 1 - .swcrc | 56 -------------------------------- package-lock.json | 6 ++-- package.json | 16 ++++----- src/commands/General/info.ts | 1 + src/utils/functions/resolvers.ts | 1 + tsconfig.json | 8 ++--- 7 files changed, 17 insertions(+), 72 deletions(-) delete mode 100644 .swcrc diff --git a/.docker/app/Dockerfile b/.docker/app/Dockerfile index 6f715954..023b0fbc 100644 --- a/.docker/app/Dockerfile +++ b/.docker/app/Dockerfile @@ -13,7 +13,6 @@ COPY src ./src # and install dependencies for plugins (because postinstall script doesn't work in docker) RUN npm ci -COPY .swcrc . COPY tsconfig.json . # Build project diff --git a/.swcrc b/.swcrc deleted file mode 100644 index 6a5142f8..00000000 --- a/.swcrc +++ /dev/null @@ -1,56 +0,0 @@ -{ - "jsc": { - "parser": { - "syntax": "typescript", - "tsx": false, - "decorators": true, - "dynamicImport": true - }, - "target": "es2021", - "baseUrl": "./", - "paths": { - - "@decorators": ["src/utils/decorators"], - "@decorators/*": ["src/plugins/*/utils/decorators"], - - "@errors": ["src/utils/errors"], - "@errors/*": ["src/plugins/*/utils/errors"], - - "@entities": ["src/entities"], - "@entities/*": ["src/plugins/*/entities"], - - "@guards": ["src/guards"], - "@guards/*": ["src/plugins/*/guards"], - - "@services": ["src/services"], - "@services/*": ["src/plugins/*/services"], - - "@i18n": ["src/i18n"], - "@i18n/*": ["src/plugins/*/i18n"], - - "@configs": ["src/configs"], - "@configs/*": ["src/plugins/*/configs"], - - "@utils/classes": ["src/utils/classes"], - "@utils/classes/*": ["src/plugins/*/utils/classes"], - - "@utils/functions": ["src/utils/functions"], - "@utils/functions/*": ["src/plugins/*/utils/functions"], - - "@api/controllers": ["src/api/controllers"], - "@api/controllers/*": ["src/plugins/*/api/controllers"], - - "@api/middlewares": ["src/api/middlewares"], - "@api/middlewares/*": ["src/plugins/*/api/middlewares"], - - "@api/server": ["src/api/server.ts"] - }, - "transform": { - "decoratorMetadata": true - } - }, - "exclude": ["node_modules", ".git"], - "module": { - "type": "commonjs" - } -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f175f99d..c7640cd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12176,9 +12176,9 @@ "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==" }, "node_modules/tsc-alias": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.5.tgz", - "integrity": "sha512-Y3ka0olwSRdbHPyX5kXhYY2aoBKuT53DFdeY+PpQUR4hg5M/b8eIRmC8dL4FBdd0wT366iWc6iDUUGe6QwI7mg==", + "version": "1.8.8", + "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.8.tgz", + "integrity": "sha512-OYUOd2wl0H858NvABWr/BoSKNERw3N9GTi3rHPK8Iv4O1UyUXIrTTOAZNHsjlVpXFOhpJBVARI1s+rzwLivN3Q==", "dev": true, "dependencies": { "chokidar": "^3.5.3", diff --git a/package.json b/package.json index a4751006..33935c05 100644 --- a/package.json +++ b/package.json @@ -5,17 +5,17 @@ "license": "MIT", "main": "build/main.js", "scripts": { - "build": "npm run build:clean && npm run build:compile && npm run build:plugins && npm run type:check", - "build:start": "npm run build && npm run start", - "build:compile": "swc src -d build -D && rimraf build/plugins/**/node_modules/", + "build": "npm run build:clean && npm run build:compile && npm run install:plugins", "build:clean": "rimraf build/", - "build:plugins": "installoop --rootDir=./build/plugins", + "build:compile": "tsc --project tsconfig.json --skipLibCheck && npm run build:alias", + "build:alias": "tsc-alias -p tsconfig.json", + "build:start": "npm run build && npm run start", + "install:plugins": "installoop --rootDir=./build/plugins", + "type:check": "tsc --pretty --skipLibCheck --noEmit", "start": "cross-env NODE_ENV=production node build/main.js", - "dev": "cross-env NODE_ENV=development nodemon --exec node -r @swc-node/register src/main.ts", - "dev:start": "cross-env NODE_ENV=production node -r @swc-node/register src/main.ts", - "dev:compile": "swc src -w -d build", + "dev": "cross-env NODE_ENV=development nodemon --exec node --loader ts-node/esm/transpile-only src/main.ts", + "dev:start": "cross-env NODE_ENV=production node --loader ts-node/esm/transpile-only src/main.ts", "i18n": "typesafe-i18n", - "type:check": "tsc --pretty --skipLibCheck --noEmit", "migration:create": "npx mikro-orm migration:create", "migration:up": "npx mikro-orm migration:up", "migration:down": "npx mikro-orm migration:down", diff --git a/src/commands/General/info.ts b/src/commands/General/info.ts index 6e7751c8..e71820ae 100644 --- a/src/commands/General/info.ts +++ b/src/commands/General/info.ts @@ -12,6 +12,7 @@ import { Guard } from "@guards" import { Stats } from "@services" import { getColor, getTscordVersion, isValidUrl, timeAgo } from "@utils/functions" +// @ts-ignore - because it is outside the `rootDir` of tsconfig import packageJson from "../../../package.json" const links = [ diff --git a/src/utils/functions/resolvers.ts b/src/utils/functions/resolvers.ts index 23d3db70..ba377010 100644 --- a/src/utils/functions/resolvers.ts +++ b/src/utils/functions/resolvers.ts @@ -13,6 +13,7 @@ import { Interaction, } from "discord.js" +// @ts-ignore - because it is outside the `rootDir` of tsconfig import packageJson from "../../../package.json" const resolvers = { diff --git a/tsconfig.json b/tsconfig.json index afa836da..283df888 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,8 @@ "target": "es2021", "module": "commonjs", - "outDir": "./build", - "rootDir": ".", + "outDir": "build", + "rootDir": "src", "strict": true, "strictPropertyInitialization": false, "moduleResolution": "node", @@ -59,8 +59,8 @@ } }, - "include": ["src", "**/*.ts"], - "exclude": ["build", "node_modules", "tests"], + "include": ["src", "**/*.ts", "src/**/*.json"], + "exclude": ["build", "node_modules", "tests", "mikro-orm.config.ts", "package.json"], "paths": ["node_modules/*", "src/utils/types/*", "src/plugins/*/utils/types/*"], "ts-node": {