From 635ad53ae415361ccd3bb7670fecf7269759bee8 Mon Sep 17 00:00:00 2001 From: gh Date: Fri, 28 Jun 2024 00:52:00 +0900 Subject: [PATCH] chore: apply swc & scripting --- .swcrc | 16 ++++++++++++++++ nest-cli.json | 5 ++++- package.json | 27 +++++++++++++++++++++------ webpack.config.ts | 2 +- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 .swcrc diff --git a/.swcrc b/.swcrc new file mode 100644 index 0000000..33bbf5b --- /dev/null +++ b/.swcrc @@ -0,0 +1,16 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": false, + "decorators": true + }, + "transform": { + "decoratorMetadata": true + }, + "target": "es2017" + }, + "module": { + "type": "commonjs" + } +} diff --git a/nest-cli.json b/nest-cli.json index f9aa683..957eed0 100644 --- a/nest-cli.json +++ b/nest-cli.json @@ -1,8 +1,11 @@ { "$schema": "https://json.schemastore.org/nest-cli", "collection": "@nestjs/schematics", + "entryFile": "handler", "sourceRoot": "src", "compilerOptions": { - "deleteOutDir": true + "deleteOutDir": true, + "builder": "swc", + "typeCheck": true } } diff --git a/package.json b/package.json index 9a59ad3..9bc7fc9 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,16 @@ "private": true, "license": "UNLICENSED", "scripts": { - "build": "nest build", + "prebuild": "if [ -d dist ]; then rm -r dist; fi", + "build": "npx webpack", + "deploy": "npm run build && sls deploy && npm run postdeploy", + "postdeploy": "if [ -d .serverless ]; then rm -r .serverless; fi", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "db:up": "docker-compose up -d", "db:down": "docker compose down", - "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", + "start": "NODE_ENV=local nest start", + "start:dev": "NODE_ENV=local nest start --watch", + "start:prod": "if [ -d dist ]; then node dist/main; fi", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", @@ -28,9 +30,12 @@ "@nestjs/mongoose": "^10.0.6", "@nestjs/platform-express": "^10.0.0", "@nestjs/swagger": "^7.3.1", + "aws-lambda": "^1.0.7", + "aws-serverless-express": "^3.4.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cross-env": "^7.0.3", + "express": "^4.19.2", "mongoose": "^8.4.1", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1" @@ -39,24 +44,34 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@swc/cli": "^0.3.14", + "@swc/core": "^1.6.5", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", + "copy-webpack-plugin": "^12.0.2", "eslint": "^8.42.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "jest": "^29.5.0", "prettier": "^3.0.0", + "serverless": "^4.1.6", + "serverless-domain-manager": "^7.3.8", + "serverless-dotenv-plugin": "^6.0.0", + "serverless-offline": "^13.6.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", + "swc-loader": "^0.2.6", "ts-jest": "^29.1.0", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" + "typescript": "^5.1.3", + "webpack": "^5.92.1", + "webpack-cli": "^5.1.4" }, "jest": { "moduleFileExtensions": [ diff --git a/webpack.config.ts b/webpack.config.ts index 5363fbd..8db3a62 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -84,7 +84,7 @@ module.exports = { libraryTarget: 'commonjs', }, module: { - rules: [{ test: /\.ts$/, loader: 'ts-loader' }], + rules: [{ test: /\.ts$/, loader: 'swc-loader' }], }, stats: { warningsFilter: [