chore(api): compile TS into /dist (#49812

* chore: compile TS into /dist

Having the output co-located with the source meant that the js would be
imported by default. Given that we don't recompile on source changes,
this means the server got 'stuck' at the point of compilation and would
only register changes on build.

Also, compiling to a dist directory should make it easier to build when
we want to deploy. That said, the motivation is mostly DX.

* fix: put schema.prisma in the default location
This commit is contained in:
Oliver Eyton-Williams
2023-03-28 16:12:20 +02:00
committed by GitHub
parent bf3aa621e9
commit a128dd8fcd
21 changed files with 20 additions and 9 deletions
-3
View File
@@ -222,6 +222,3 @@ client/src/components/Donation/types.js
### UI Components ###
tools/ui-components/dist
### API ###
api/**/*.js
+1
View File
@@ -0,0 +1 @@
dist/**/*.js
+4 -3
View File
@@ -50,9 +50,10 @@
"url": "git+https://github.com/freeCodeCamp/freeCodeCamp.git"
},
"scripts": {
"build": "tsc",
"develop": "nodemon server.ts",
"start": "NODE_ENV=production node server.js",
"build": "tsc -p tsconfig.build.json",
"clean": "rm -rf dist",
"develop": "nodemon src/server.ts",
"start": "NODE_ENV=production node dist/server.js",
"test": "jest --force-exit",
"prisma": "MONGOHQ_URL=mongodb://localhost:27017/freecodecamp?directConnection=true prisma",
"postinstall": "prisma generate"
View File
View File
+1 -1
View File
@@ -2,7 +2,7 @@ import assert from 'node:assert';
import path from 'node:path';
import { config } from 'dotenv';
const envPath = path.resolve(__dirname, '../../.env');
const envPath = path.resolve(__dirname, '../../../.env');
const { error } = config({ path: envPath });
if (error) {
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"noEmit": false
},
"include": ["src"],
"exclude": ["**/*.test.*", "**/__mocks__/*", "**/__tests__/*"]
}
+3 -2
View File
@@ -2,10 +2,11 @@
"compilerOptions": {
"target": "es2022",
"module": "CommonJS",
"allowJs": true,
"allowJs": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"noEmit": true
}
}
+1
View File
@@ -32,6 +32,7 @@
"challenge-editor:server": "cd ./tools/challenge-editor/api && pnpm start",
"clean": "npm-run-all -p clean:client clean:server clean:curriculum --serial clean:packages",
"clean-and-develop": "pnpm run clean && pnpm install && pnpm run develop",
"clean:api": "cd api && pnpm clean",
"clean:client": "cd ./client && pnpm run clean",
"clean:curriculum": "rm -rf ./config/curriculum.json",
"clean:packages": "rm -rf ./node_modules ./**/node_modules",