Skip to content

Commit

Permalink
🔧 Use SWC to build backend
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRobertAnsart committed Jun 25, 2022
1 parent f911318 commit 02316a5
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 8 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,29 @@ on:
branches: [master]

jobs:
server_tsc:
runs-on: ubuntu-latest
steps:
# [1] checkout repo.
- uses: actions/checkout@v2

# [2] get node.
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '16.15.1'

# [3] install dependencies.
- name: Install dependencies
run: yarn

# [4] test typescript.
- name: Run typescript
run: yarn typescript:server

deploy:
runs-on: ubuntu-latest
needs: server_tsc # check server types before building.
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# [4] test typescript.
- name: Run typescript
run: yarn typscript
run: yarn typescript

lint:
runs-on: ubuntu-latest
Expand Down
39 changes: 39 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": false
},
"target": "es2021",
"keepClassNames": true,
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
}
},
"module": {
"type": "commonjs",
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false
}
}
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ COPY .eslintignore .
COPY .eslintrc.js .
COPY .prettierrc.js .
COPY .svgrrc.js .
COPY .swcrc .
COPY nodemon.json .
COPY next-env.d.ts .
COPY next.config.js .
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ COPY .eslintignore ./
COPY .eslintrc.js ./
COPY .prettierrc.js ./
COPY .svgrrc.js ./
COPY .swcrc ./
COPY nodemon.json ./
COPY next-env.d.ts ./
COPY next.config.js ./
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"scripts": {
"copy:templates": "yarn cpx 'server/emails/templates/*' 'dist/server/emails/templates'",
"build:next": "next build",
"build:server": "tsc --project server/tsconfig.json && yarn copy:templates",
"build:server": "swc ./server -d dist/server && swc ./types -d dist/types && yarn copy:templates",
"build": "rm -rf dist && NODE_ENV=production yarn build:next && yarn build:server",
"lint": "yarn eslint src && yarn eslint server",
"lint:fix": "yarn eslint src --fix && yarn eslint server --fix",
"typscript": "yarn tsc -p . && yarn tsc --project server/tsconfig.json --noEmit",
"lint": "yarn eslint .",
"lint:fix": "yarn eslint . --fix",
"typescript:server": "yarn tsc --project server/tsconfig.json --noEmit",
"typescript": "yarn tsc -p . && yarn typescript:server",
"test": "yarn jest",
"start-dev": "yarn build:server && node dist/server/start.js",
"start": "NODE_ENV=production node dist/server/start.js",
Expand All @@ -35,6 +36,7 @@
"devDependencies": {
"@next/eslint-plugin-next": "^12.1.6",
"@svgr/webpack": "6.2.1",
"@swc/cli": "^0.1.57",
"@swc/core": "1.2.205",
"@swc/jest": "0.2.21",
"@types/cookie-parser": "1.4.3",
Expand Down
35 changes: 32 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __metadata:
"@mui/system": ^5.8.5
"@next/eslint-plugin-next": ^12.1.6
"@svgr/webpack": 6.2.1
"@swc/cli": ^0.1.57
"@swc/core": 1.2.205
"@swc/jest": 0.2.21
"@types/cookie-parser": 1.4.3
Expand Down Expand Up @@ -3256,6 +3257,27 @@ __metadata:
languageName: node
linkType: hard

"@swc/cli@npm:^0.1.57":
version: 0.1.57
resolution: "@swc/cli@npm:0.1.57"
dependencies:
commander: ^7.1.0
fast-glob: ^3.2.5
slash: 3.0.0
source-map: ^0.7.3
peerDependencies:
"@swc/core": ^1.2.66
chokidar: ^3.5.1
peerDependenciesMeta:
chokidar:
optional: true
bin:
spack: bin/spack.js
swc: bin/swc.js
checksum: d19f02233f5ca18df9d5e9da1d0c847d47c81f4548d8465553b9c54b9ab0aca6ebc61b47f1eff085fe211aea0594e0c694bac3d5097f836fbfaa40d31d0a8dfd
languageName: node
linkType: hard

"@swc/core-android-arm-eabi@npm:1.2.205":
version: 1.2.205
resolution: "@swc/core-android-arm-eabi@npm:1.2.205"
Expand Down Expand Up @@ -6195,7 +6217,7 @@ __metadata:
languageName: node
linkType: hard

"commander@npm:^7.2.0":
"commander@npm:^7.1.0, commander@npm:^7.2.0":
version: 7.2.0
resolution: "commander@npm:7.2.0"
checksum: 53501cbeee61d5157546c0bef0fedb6cdfc763a882136284bed9a07225f09a14b82d2a84e7637edfd1a679fb35ed9502fd58ef1d091e6287f60d790147f68ddc
Expand Down Expand Up @@ -7828,7 +7850,7 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:^3.2.9":
"fast-glob@npm:^3.2.5, fast-glob@npm:^3.2.9":
version: 3.2.11
resolution: "fast-glob@npm:3.2.11"
dependencies:
Expand Down Expand Up @@ -13267,7 +13289,7 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"slash@npm:^3.0.0":
"slash@npm:3.0.0, slash@npm:^3.0.0":
version: 3.0.0
resolution: "slash@npm:3.0.0"
checksum: 94a93fff615f25a999ad4b83c9d5e257a7280c90a32a7cb8b4a87996e4babf322e469c42b7f649fd5796edd8687652f3fb452a86dc97a816f01113183393f11c
Expand Down Expand Up @@ -13420,6 +13442,13 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"source-map@npm:^0.7.3":
version: 0.7.4
resolution: "source-map@npm:0.7.4"
checksum: 01cc5a74b1f0e1d626a58d36ad6898ea820567e87f18dfc9d24a9843a351aaa2ec09b87422589906d6ff1deed29693e176194dc88bcae7c9a852dc74b311dbf5
languageName: node
linkType: hard

"source-map@npm:~0.7.2":
version: 0.7.3
resolution: "source-map@npm:0.7.3"
Expand Down

0 comments on commit 02316a5

Please sign in to comment.