From 71d1d363ad5af7753f09e3f2300ac88e5b68a139 Mon Sep 17 00:00:00 2001 From: Oscar Busk Date: Wed, 12 Dec 2018 11:04:39 +0100 Subject: [PATCH] Fix/update "examples/custom-server-typescript" (#5865) * Update all dependencies and remove redundant ones from package.json. (60f9ee5) * Fixes #5596 by adjusting nodemon scripts (d4b7d3a) * Fixes `npm start` on windows by using `cross-env` (9555217) * Move compiled server out from `.next`. Compiling other JS into `.next` seems incorrect. (79fce02, 9ce7086) * Partly fixes #5753 by making sure typescript compiles with `es2017` as target, at least ensuring code is runnable on node 8. Previously it was compiled with `esnext`. (9176e92) --- I tried improving the structure by keeping source in `src/app` and `src/server` and then building to `dist/server` and `dist/app` but I didn't really get it to work and made most configs more complicated. Moved the built server out from `.next` anyway. --- examples/custom-server-typescript/.gitignore | 8 ++++++ .../custom-server-typescript/nodemon.json | 4 +-- .../custom-server-typescript/package.json | 26 +++++++++---------- .../tsconfig.server.json | 6 ++++- 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 examples/custom-server-typescript/.gitignore diff --git a/examples/custom-server-typescript/.gitignore b/examples/custom-server-typescript/.gitignore new file mode 100644 index 00000000..5e94be3d --- /dev/null +++ b/examples/custom-server-typescript/.gitignore @@ -0,0 +1,8 @@ +# Dependency directories +node_modules/ + +# next.js build output +.next + +# typescript build output +dist diff --git a/examples/custom-server-typescript/nodemon.json b/examples/custom-server-typescript/nodemon.json index 2df1d50d..b322d5cc 100644 --- a/examples/custom-server-typescript/nodemon.json +++ b/examples/custom-server-typescript/nodemon.json @@ -1,6 +1,4 @@ { "watch": ["server/**/*.ts"], - "execMap": { - "ts": "ts-node --typeCheck --compilerOptions '{\"module\":\"commonjs\"}'" - } + "exec": "ts-node --project tsconfig.server.json server/index.ts" } diff --git a/examples/custom-server-typescript/package.json b/examples/custom-server-typescript/package.json index e21c7807..6d9998ad 100644 --- a/examples/custom-server-typescript/package.json +++ b/examples/custom-server-typescript/package.json @@ -1,23 +1,21 @@ { "scripts": { - "dev": "nodemon server/index.ts", + "dev": "nodemon", "build": "next build && tsc --project tsconfig.server.json", - "start": "NODE_ENV=production node .next/production-server/index.js" + "start": "cross-env NODE_ENV=production node dist/index.js" }, "dependencies": { - "@babel/core": "^7.1.2", - "@zeit/next-typescript": "1.1.1", - "babel-loader": "^8.0.4", - "next": "latest", - "react": "^16.5.2", - "react-dom": "^16.5.2", - "typescript": "latest", - "typescript-babel-jest": "^1.0.5" + "@zeit/next-typescript": "^1.1.0", + "next": "^7.0.0", + "react": "^16.6.0", + "react-dom": "^16.6.0" }, "devDependencies": { - "@types/next": "^7.0.1", - "@types/react": "^16.4.16", - "nodemon": "^1.18.4", - "ts-node": "^7.0.1" + "@types/next": "^7.0.0", + "@types/react": "^16.6.0", + "cross-env": "^5.2.0", + "nodemon": "^1.18.8", + "ts-node": "^7.0.1", + "typescript": "^3.2.0" } } diff --git a/examples/custom-server-typescript/tsconfig.server.json b/examples/custom-server-typescript/tsconfig.server.json index 7376870e..6f83ee32 100644 --- a/examples/custom-server-typescript/tsconfig.server.json +++ b/examples/custom-server-typescript/tsconfig.server.json @@ -2,7 +2,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "outDir": ".next/production-server/" + "outDir": "dist", + "target": "es2017", + "lib": [ + "es2017" + ] }, "include": ["server/**/*.ts"] }