perf: 👷 build backend with swc

Co-authored-by: pikokr <@paring@pikokr.dev>
This commit is contained in:
ThatOneCalculator 2023-01-10 16:48:49 -08:00
parent 56bb3ac355
commit 98401ff312
No known key found for this signature in database
GPG key ID: 8703CACD01000000
6 changed files with 1033 additions and 60 deletions

25
packages/backend/.swcrc Normal file
View file

@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"dynamicImport": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"experimental": {
"keepImportAssertions": true
},
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
},
"target": "es2022"
},
"minify": false
}

View file

@ -8,8 +8,8 @@
"start:test": "NODE_ENV=test yarn node ./built/index.js", "start:test": "NODE_ENV=test yarn node ./built/index.js",
"migrate": "typeorm migration:run -d ormconfig.js", "migrate": "typeorm migration:run -d ormconfig.js",
"revertmigration": "typeorm migration:revert -d ormconfig.js", "revertmigration": "typeorm migration:revert -d ormconfig.js",
"build": "tsc -p tsconfig.json || echo done. && tsc-alias -p tsconfig.json", "build": "swc src -d built -D",
"watch": "yarn node watch.mjs", "watch": "swc src -d built -D -w",
"lint": "eslint --quiet \"src/**/*.ts\"", "lint": "eslint --quiet \"src/**/*.ts\"",
"mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha", "mocha": "cross-env NODE_ENV=test TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT=\"./test/tsconfig.json\" mocha",
"test": "yarn run mocha" "test": "yarn run mocha"
@ -77,7 +77,7 @@
"koa-send": "5.0.1", "koa-send": "5.0.1",
"koa-slow": "2.1.0", "koa-slow": "2.1.0",
"koa-views": "7.0.2", "koa-views": "7.0.2",
"mfm-js": "0.23.0", "mfm-js": "0.23.2",
"mime-types": "2.1.35", "mime-types": "2.1.35",
"mocha": "10.2.0", "mocha": "10.2.0",
"multer": "1.4.4-lts.1", "multer": "1.4.4-lts.1",
@ -119,7 +119,6 @@
"tmp": "0.2.1", "tmp": "0.2.1",
"ts-loader": "9.4.2", "ts-loader": "9.4.2",
"ts-node": "10.9.1", "ts-node": "10.9.1",
"tsc-alias": "1.8.2",
"tsconfig-paths": "4.1.2", "tsconfig-paths": "4.1.2",
"twemoji-parser": "14.0.0", "twemoji-parser": "14.0.0",
"typeorm": "0.3.11", "typeorm": "0.3.11",
@ -132,7 +131,9 @@
"xev": "3.0.2" "xev": "3.0.2"
}, },
"devDependencies": { "devDependencies": {
"@redocly/openapi-core": "1.0.0-beta.119", "@redocly/openapi-core": "1.0.0-beta.120",
"@swc/cli": "^0.1.59",
"@swc/core": "^1.3.25",
"@types/bcryptjs": "2.4.2", "@types/bcryptjs": "2.4.2",
"@types/bull": "3.15.9", "@types/bull": "3.15.9",
"@types/cbor": "6.0.0", "@types/cbor": "6.0.0",

View file

@ -60,6 +60,7 @@ html
meta(property='og:title' content=title || 'Calckey') meta(property='og:title' content=title || 'Calckey')
meta(property='og:description' content=desc || 'An open source, decentralized social media platform that\'s free forever! 🚀') meta(property='og:description' content=desc || 'An open source, decentralized social media platform that\'s free forever! 🚀')
meta(property='og:image' content=img) meta(property='og:image' content=img)
meta(property='og:image:alt' content=alt || 'Pfp')
style style
include ../style.css include ../style.css

View file

@ -1,23 +0,0 @@
import { execa } from 'execa';
(async () => {
// なぜかchokidarが動かない影響で、watchされない
/*
execa('tsc-alias', ['-w', '-p', 'tsconfig.json'], {
stdout: process.stdout,
stderr: process.stderr,
});
*/
setInterval(() => {
execa('tsc-alias', ['-p', 'tsconfig.json'], {
stdout: process.stdout,
stderr: process.stderr,
});
}, 3000);
execa('tsc', ['-w', '-p', 'tsconfig.json'], {
stdout: process.stdout,
stderr: process.stderr,
});
})();

View file

@ -34,7 +34,7 @@
"json5": "2.2.3", "json5": "2.2.3",
"katex": "0.16.4", "katex": "0.16.4",
"matter-js": "0.18.0", "matter-js": "0.18.0",
"mfm-js": "0.23.0", "mfm-js": "0.23.2",
"photoswipe": "5.3.4", "photoswipe": "5.3.4",
"prismjs": "1.29.0", "prismjs": "1.29.0",
"punycode": "2.1.1", "punycode": "2.1.1",

1031
yarn.lock

File diff suppressed because it is too large Load diff