Skip to content

Commit

Permalink
fix(be): apply swc on nest
Browse files Browse the repository at this point in the history
  • Loading branch information
jspark2000 committed Sep 7, 2024
1 parent 886c3d4 commit 6049db7
Show file tree
Hide file tree
Showing 7 changed files with 957 additions and 85 deletions.
6 changes: 1 addition & 5 deletions apps/backend/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"$schema": "https://json.schemastore.org/mocharc",
"extension": "spec.ts",
"require": [
"ts-node/register/transpile-only",
"tsconfig-paths/register",
"./mocha-fixture.ts"
],
"require": ["@swc-node/register", "./mocha-fixture.ts"],
"reporter": "dot"
}
20 changes: 7 additions & 13 deletions apps/backend/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
"decorators": true,
"dynamicImport": true
},
"baseUrl": "./",
"paths": {
"@admin/*": ["./apps/admin/src/*"],
"@client/*": ["./apps/client/src/*"],
"@libs/prisma": ["./libs/prisma/src/index.ts"],
"@libs/cache": ["./libs/cache/src/index.ts"],
"@libs/auth": ["libs/auth/src/index.ts"],
"@libs/exception": ["libs/exception/src/index.ts"],
"@libs/pipe": ["libs/pipe/src/index.ts"],
"@libs/constants": ["libs/constants/src/index.ts"]
"@libs/auth": ["./libs/auth/src/index.ts"],
"@libs/exception": ["./libs/exception/src/index.ts"],
"@libs/pipe": ["./libs/pipe/src/index.ts"],
"@libs/constants": ["./libs/constants/src/index.ts"]
}
},
"module": {
"type": "commonjs",
"noInterop": true
}
}
2 changes: 1 addition & 1 deletion apps/backend/apps/client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ValidationPipe } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import * as cookieParser from 'cookie-parser'
import cookieParser from 'cookie-parser'
import { Logger, LoggerErrorInterceptor } from 'nestjs-pino'
import { AppModule } from './app.module'
import startMetricsExporter from './metric'
Expand Down
9 changes: 8 additions & 1 deletion apps/backend/nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
}
],
"watchAssets": true,
"webpack": true,
"deleteOutDir": true,
"plugins": ["@nestjs/swagger"],
"builder": "webpack",
"builder": {
"type": "swc",
"options": {
"swcrcPath": ".swcrc"
}
},
"webpackConfigPath": "webpack.config.js",
"tsConfigPath": "apps/client/tsconfig.app.json"
},
"monorepo": true,
Expand Down
8 changes: 7 additions & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"cross-env": "^7.0.3",
"dayjs": "^1.11.13",
"exceljs": "^4.4.0",
"express": "^4.19.2",
"generate-password": "^1.7.1",
"graphql": "^16.9.0",
"graphql-type-json": "^0.3.2",
Expand All @@ -84,6 +85,9 @@
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.1",
"@swc-node/register": "^1.10.9",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.23",
"@types/cache-manager": "^4.0.6",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^7.1.8",
Expand All @@ -104,12 +108,14 @@
"proxyquire": "^2.1.3",
"sinon": "^18.0.0",
"source-map-support": "^0.5.21",
"swc-loader": "^0.2.6",
"swc-node": "^1.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.5.4"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
"seed": "swc-node prisma/seed.ts"
}
}
18 changes: 18 additions & 0 deletions apps/backend/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const swcDefaultConfig =
require('@nestjs/cli/lib/compiler/defaults/swc-defaults').swcDefaultsFactory()
.swcOptions

module.exports = {
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: 'swc-loader',
options: swcDefaultConfig
}
}
]
}
}
Loading

0 comments on commit 6049db7

Please sign in to comment.