Skip to content

Commit 04101ed

Browse files
authored
Add Next.js frontend and use vercel-dev-runtime (#8)
* Add Next.js frontend and use `vercel-dev-runtime` * Update root tsconfig * Ensure the `build.sh` and `bootstrap` files are executable
1 parent 5194b67 commit 04101ed

11 files changed

+4574
-71
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/node_modules
22
/dist
33
/*.tgz
4-
.vercel
4+
/.next
5+
/.vercel

.vercelignore

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/node_modules
2-
/yarn.lock
3-
/package.json
4-
/tsconfig.json
52
/README.md
6-
/src
73
/dist
84
/test
95
/.*
106
/*.tgz
7+
/.next
8+
/.vercel

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
],
1717
"scripts": {
1818
"prebuild": "rimraf dist",
19-
"build": "tsc",
19+
"build": "tsc --project src/tsconfig.json",
2020
"postbuild": "cpy src '!**/*.ts' dist",
21+
"now-build": "next build",
2122
"prepublishOnly": "npm run build"
2223
},
2324
"dependencies": {
@@ -26,6 +27,7 @@
2627
},
2728
"devDependencies": {
2829
"@types/node": "^12.12.17",
30+
"@types/react": "^16.9.41",
2931
"@typescript-eslint/eslint-plugin": "1.6.0",
3032
"@typescript-eslint/parser": "1.1.0",
3133
"@vercel/build-utils": "^2.3.1",
@@ -39,7 +41,10 @@
3941
"eslint-plugin-import": "2.16.0",
4042
"eslint-plugin-jsx-a11y": "6.2.1",
4143
"eslint-plugin-react": "7.12.4",
44+
"next": "^9.4.4",
45+
"react": "^16.13.1",
46+
"react-dom": "^16.13.1",
4247
"rimraf": "^3.0.0",
43-
"typescript": "^3.5.3"
48+
"typescript": "^3.9.3"
4449
}
4550
}

pages/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default () => {
2+
return <div>Hello Bash</div>;
3+
};
File renamed without changes.

src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'fs';
12
import execa from 'execa';
23
import { join } from 'path';
34
import { snakeCase } from 'snake-case';
@@ -11,6 +12,11 @@ import {
1112
shouldServe
1213
} from '@vercel/build-utils';
1314

15+
// `chmod()` is required for usage with `vercel-dev-runtime`
16+
// since file mode is not preserved in Vercel deployments.
17+
fs.chmodSync(join(__dirname, 'build.sh'), 0o755);
18+
fs.chmodSync(join(__dirname, 'bootstrap'), 0o755);
19+
1420
// From this list: https://import.pw/importpw/import/docs/config.md
1521
const allowedConfigImports = new Set([
1622
'CACHE',
@@ -66,7 +72,7 @@ export async function build({
6672
ENTRYPOINT: entrypoint
6773
};
6874

69-
const builderPath = join(__dirname, 'builder.sh');
75+
const builderPath = join(__dirname, 'build.sh');
7076

7177
await execa(builderPath, [], {
7278
env,

src/tsconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"module": "CommonJS",
5+
"target": "es2018",
6+
"esModuleInterop": true,
7+
"lib": ["esnext"],
8+
"outDir": "../dist",
9+
"sourceMap": true,
10+
"declaration": true
11+
},
12+
"include": ["**/*.ts"],
13+
"exclude": ["node_modules"]
14+
}

tsconfig.json

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
{
22
"compilerOptions": {
3-
"strict": true,
4-
"module": "CommonJS",
5-
"target": "es2015",
3+
"target": "es5",
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
9+
"allowJs": true,
10+
"skipLibCheck": true,
11+
"strict": false,
12+
"forceConsistentCasingInFileNames": true,
13+
"noEmit": true,
614
"esModuleInterop": true,
7-
"lib": ["esnext"],
8-
"outDir": "dist",
9-
"sourceMap": true,
10-
"declaration": true
15+
"module": "esnext",
16+
"moduleResolution": "node",
17+
"resolveJsonModule": true,
18+
"isolatedModules": true,
19+
"jsx": "preserve"
1120
},
12-
"include": ["src/**/*"],
13-
"exclude": ["node_modules"]
21+
"exclude": [
22+
"node_modules",
23+
"src"
24+
],
25+
"include": [
26+
"next-env.d.ts",
27+
"pages/*.tsx"
28+
]
1429
}

vercel.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"public": true,
33
"functions": {
4-
"api/*.sh": { "runtime": "vercel-bash@3.0.7" }
4+
"api/*.sh": { "runtime": "vercel-dev-runtime@0.0.1" }
55
}
66
}

0 commit comments

Comments
 (0)