Skip to content

Commit 923a526

Browse files
committed
Drop tsup in favor of tsc (#192)
1 parent d2fc4fe commit 923a526

35 files changed

+143
-332
lines changed

examples/api/wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "api"
3-
main = ".open-next/worker.ts"
3+
main = ".open-next/worker.js"
44
compatibility_date = "2024-09-23"
55
compatibility_flags = ["nodejs_compat"]
66

examples/create-next-app/wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "create-next-app"
3-
main = ".open-next/worker.ts"
3+
main = ".open-next/worker.js"
44

55
compatibility_date = "2024-09-23"
66
compatibility_flags = ["nodejs_compat"]

examples/middleware/wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "middleware"
3-
main = ".open-next/worker.ts"
3+
main = ".open-next/worker.js"
44
compatibility_date = "2024-09-23"
55
compatibility_flags = ["nodejs_compat"]
66

examples/vercel-blog-starter/wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "vercel-blog-starter-on-workers"
3-
main = ".open-next/worker.ts"
3+
main = ".open-next/worker.js"
44

55
compatibility_date = "2024-09-23"
66
compatibility_flags = ["nodejs_compat"]

examples/vercel-commerce/wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "vercel-commerce-on-workers"
3-
main = ".open-next/worker.ts"
3+
main = ".open-next/worker.js"
44

55
compatibility_date = "2024-09-23"
66
compatibility_flags = ["nodejs_compat"]

packages/cloudflare/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can use [`create-next-app`](https://nextjs.org/docs/pages/api-reference/cli/
2727
```toml
2828
#:schema node_modules/wrangler/config-schema.json
2929
name = "<your-app-name>"
30-
main = ".open-next/worker.ts"
30+
main = ".open-next/worker.js"
3131

3232
compatibility_date = "2024-09-23"
3333
compatibility_flags = ["nodejs_compat"]

packages/cloudflare/TODO.md

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

packages/cloudflare/package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22
"name": "@opennextjs/cloudflare",
33
"description": "Cloudflare builder for next apps",
44
"version": "0.3.0",
5+
"type": "module",
56
"scripts": {
6-
"build": "tsup",
7-
"build:watch": "tsup --watch src",
7+
"clean": "rimraf dist",
8+
"build": "pnpm clean && tsc",
9+
"build:watch": "tsc -w",
810
"lint:check": "eslint",
911
"lint:fix": "eslint --fix",
1012
"ts:check": "tsc --noEmit",
1113
"test": "vitest --run",
1214
"test:watch": "vitest"
1315
},
1416
"bin": {
15-
"opennextjs-cloudflare": "dist/cli/index.mjs"
17+
"opennextjs-cloudflare": "dist/cli/index.js"
1618
},
17-
"main": "./dist/api/index.mjs",
18-
"types": "./dist/api/index.d.mts",
19+
"main": "./dist/api/index.js",
20+
"types": "./dist/api/index.d.ts",
1921
"exports": {
2022
".": {
21-
"import": "./dist/api/index.mjs",
22-
"types": "./dist/api/index.d.mts",
23-
"default": "./dist/api/index.mjs"
23+
"import": "./dist/api/index.js",
24+
"types": "./dist/api/index.d.ts",
25+
"default": "./dist/api/index.js"
2426
}
2527
},
2628
"files": [
@@ -50,14 +52,13 @@
5052
"@types/node": "catalog:",
5153
"esbuild": "catalog:",
5254
"eslint": "catalog:",
53-
"eslint-plugin-import": "^2.31.0",
54-
"eslint-plugin-simple-import-sort": "^12.1.1",
55+
"eslint-plugin-import": "catalog:",
56+
"eslint-plugin-simple-import-sort": "catalog:",
5557
"eslint-plugin-unicorn": "catalog:",
5658
"glob": "catalog:",
5759
"globals": "catalog:",
5860
"next": "catalog:",
5961
"package-manager-detector": "catalog:",
60-
"tsup": "catalog:",
6162
"typescript": "catalog:",
6263
"typescript-eslint": "catalog:",
6364
"vitest": "catalog:",
@@ -70,6 +71,7 @@
7071
"@dotenvx/dotenvx": "catalog:"
7172
},
7273
"peerDependencies": {
74+
"rimraf": "catalog:",
7375
"wrangler": "catalog:"
7476
}
75-
}
77+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./get-cloudflare-context";
1+
export * from "./get-cloudflare-context.js";

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { fileURLToPath } from "node:url";
66
import type { BuildOptions } from "@opennextjs/aws/build/helper.js";
77
import { build, Plugin } from "esbuild";
88

9-
import { Config } from "../config";
10-
import * as patches from "./patches";
11-
import { copyPrerenderedRoutes } from "./utils";
9+
import { Config } from "../config.js";
10+
import * as patches from "./patches/index.js";
11+
import { copyPrerenderedRoutes } from "./utils/index.js";
1212

1313
/** The dist directory of the Cloudflare adapter package */
14-
const packageDistDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
14+
const packageDistDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
1515

1616
/**
1717
* Bundle the Open Next server.
@@ -51,15 +51,15 @@ export async function bundleServer(config: Config, openNextOptions: BuildOptions
5151
// Note: we apply an empty shim to next/dist/compiled/ws because it generates two `eval`s:
5252
// eval("require")("bufferutil");
5353
// eval("require")("utf-8-validate");
54-
"next/dist/compiled/ws": path.join(config.paths.internal.templates, "shims", "empty.ts"),
54+
"next/dist/compiled/ws": path.join(config.paths.internal.templates, "shims", "empty.js"),
5555
// Note: we apply an empty shim to next/dist/compiled/edge-runtime since (amongst others) it generated the following `eval`:
5656
// eval(getModuleCode)(module, module.exports, throwingRequire, params.context, ...Object.values(params.scopedContext));
5757
// which comes from https://github.com/vercel/edge-runtime/blob/6e96b55f/packages/primitives/src/primitives/load.js#L57-L63
5858
// QUESTION: Why did I encountered this but mhart didn't?
59-
"next/dist/compiled/edge-runtime": path.join(config.paths.internal.templates, "shims", "empty.ts"),
59+
"next/dist/compiled/edge-runtime": path.join(config.paths.internal.templates, "shims", "empty.js"),
6060
// `@next/env` is a library Next.js uses for loading dotenv files, for obvious reasons we need to stub it here
6161
// source: https://github.com/vercel/next.js/tree/0ac10d79720/packages/next-env
62-
"@next/env": path.join(config.paths.internal.templates, "shims", "env.ts"),
62+
"@next/env": path.join(config.paths.internal.templates, "shims", "env.js"),
6363
},
6464
define: {
6565
// config file used by Next.js, see: https://github.com/vercel/next.js/blob/68a7128/packages/next/src/build/utils.ts#L2137-L2139
@@ -188,10 +188,7 @@ function createFixRequiresESBuildPlugin(config: Config): Plugin {
188188
setup(build) {
189189
// Note: we (empty) shim require-hook modules as they generate problematic code that uses requires
190190
build.onResolve({ filter: /^\.\/require-hook$/ }, () => ({
191-
path: path.join(config.paths.internal.templates, "shims", "empty.ts"),
192-
}));
193-
build.onResolve({ filter: /\.\/lib\/node-fs-methods$/ }, () => ({
194-
path: path.join(config.paths.internal.templates, "shims", "empty.ts"),
191+
path: path.join(config.paths.internal.templates, "shims", "empty.js"),
195192
}));
196193
},
197194
};

0 commit comments

Comments
 (0)