Skip to content

Commit af23c7e

Browse files
Replace Next.js with Vercel native serverless functions (#109)
* Replace Next.js with Vercel native serverless functions * avoid vercel run next auto detection * add `”type”: “module”` to `package.json` * fix extensions * fix import flavor * drop node-fetch and use builtin fetch * update tsconfig and oxlint to error if files have no ts extension --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
1 parent 758cf4a commit af23c7e

12 files changed

Lines changed: 43 additions & 260 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
.next
2+
.next
3+
.vercel

.oxlintrc.jsonc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
"no-warning-comments": "off",
2222
"sort-keys": "off",
2323

24+
"import/extensions": [
25+
"error",
26+
{
27+
"ts": "always",
28+
"tsx": "always",
29+
"ignorePackages": true,
30+
"checkTypeImports": true,
31+
},
32+
],
33+
2434
"vitest/no-conditional-in-test": "off",
2535
"jest/no-conditional-in-test": "off",
2636

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createNodeMiddleware, createProbot } from "probot";
22

3-
import app from "../../index";
3+
import app from "../index.ts";
44

55
// Requires:
66
// - APP_ID

get-changed-packages.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import type {
1010
PackageJSON as ChangesetPackageJSON,
1111
} from "@changesets/types";
1212
import type { Packages, Tool } from "@manypkg/get-packages";
13-
import { safeLoad } from "js-yaml";
13+
import jsYaml from "js-yaml";
1414
import micromatch from "micromatch";
15-
import fetch from "node-fetch";
1615
import type { ProbotOctokit } from "probot";
1716

1817
interface PackageJSON extends ChangesetPackageJSON {
@@ -148,7 +147,7 @@ export const getChangedPackages = async ({
148147

149148
if (isPnpm) {
150149
const pnpmWorkspaceContent = await fetchTextFile("pnpm-workspace.yaml");
151-
const pnpmWorkspace = safeLoad(pnpmWorkspaceContent) as PnpmWorkspace;
150+
const pnpmWorkspace = jsYaml.safeLoad(pnpmWorkspaceContent) as PnpmWorkspace;
152151

153152
if (pnpmWorkspace.packages) {
154153
tool = {

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import humanId from "human-id";
66
import markdownTable from "markdown-table";
77
import type { Probot, Context } from "probot";
88

9-
import { getChangedPackages } from "./get-changed-packages";
9+
import { getChangedPackages } from "./get-changed-packages.ts";
1010

1111
const getReleasePlanMessage = (releasePlan: ReleasePlan | null) => {
1212
if (!releasePlan) return "";

knip.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/knip/schema.json",
3+
"entry": ["api/**/*.ts"]
4+
}

next-env.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"homepage": "https://github.com/apps/changeset-bot",
66
"license": "MIT",
77
"repository": "https://github.com/changesets/bot",
8+
"type": "module",
89
"scripts": {
910
"format": "oxfmt",
1011
"format:check": "oxfmt --check",
@@ -29,22 +30,14 @@
2930
"@types/markdown-table": "^2.0.0",
3031
"@types/micromatch": "^4.0.1",
3132
"@types/node": "^25.5.0",
32-
"@types/node-fetch": "^2.5.5",
33-
"@types/react": "^18.0.14",
34-
"@types/react-dom": "^18.0.5",
3533
"human-id": "^1.0.2",
3634
"js-yaml": "^3.14.0",
3735
"markdown-table": "^2.0.0",
3836
"micromatch": "^4.0.2",
39-
"next": "^12.1.6",
40-
"node-fetch": "^2.6.1",
4137
"probot": "^12.2.4",
42-
"react": "^18.2.0",
43-
"react-dom": "^18.2.0",
4438
"typescript": "^6.0.2"
4539
},
4640
"devDependencies": {
47-
"@tsconfig/next": "^2.0.6",
4841
"knip": "^6.11.0",
4942
"msw": "^2.12.14",
5043
"oxfmt": "^0.42.0",

test/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { setupServer } from "msw/node";
66
import { Probot, ProbotOctokit } from "probot";
77
import { aroundEach, beforeAll, describe, it } from "vitest";
88

9-
import type { PRContext } from "../index";
10-
import changesetBot from "../index";
9+
import type { PRContext } from "../index.ts";
10+
import changesetBot from "../index.ts";
1111

1212
import pullRequestOpen from "./fixtures/pull_request.opened.json";
1313
import pullRequestSynchronize from "./fixtures/pull_request.synchronize.json";

tsconfig.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{
2-
"extends": "@tsconfig/next/tsconfig.json",
32
"compilerOptions": {
4-
"allowJs": false,
5-
"tsBuildInfoFile": "node_modules/.cache/.tsbuildinfo",
6-
"forceConsistentCasingInFileNames": true,
3+
"target": "esnext",
4+
"module": "node16",
5+
"moduleResolution": "node16",
6+
"noEmit": true,
77
"strict": true,
8-
"moduleResolution": "bundler"
8+
"forceConsistentCasingInFileNames": true,
9+
"allowImportingTsExtensions": true,
10+
"rewriteRelativeImportExtensions": true,
11+
"skipLibCheck": true,
12+
"lib": ["esnext"],
13+
"allowJs": false,
14+
"incremental": false,
15+
"resolveJsonModule": true,
16+
"isolatedModules": true
917
},
10-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
18+
"include": ["**/*.ts"],
1119
"exclude": ["node_modules"]
1220
}

0 commit comments

Comments
 (0)