Skip to content

Commit 57b9b17

Browse files
committed
debugging ci vite-cloudflare-test.ts issues
1) Set compatibility_date to remove warnings about the date missing 2) Remove wrangler type import from generated load-context.ts file - I've aligned the types with the cloudflare template
1 parent 1a389df commit 57b9b17

File tree

7 files changed

+59
-48
lines changed

7 files changed

+59
-48
lines changed

integration/helpers/cloudflare-dev-proxy-template/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
"react-router": "workspace:*"
2020
},
2121
"devDependencies": {
22+
"@cloudflare/workers-types": "^4.20250317.0",
2223
"@react-router/dev": "workspace:*",
2324
"@react-router/fs-routes": "workspace:*",
2425
"@react-router/remix-routes-option-adapter": "workspace:*",
2526
"@types/react": "^18.2.20",
2627
"@types/react-dom": "^18.2.7",
2728
"typescript": "^5.1.6",
2829
"vite": "^6.1.0",
29-
"wrangler": "^4.1.0"
30+
"wrangler": "^4.2.0"
3031
},
3132
"engines": {
3233
"node": ">=20.0.0"

integration/helpers/cloudflare-dev-proxy-template/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["env.d.ts", "**/*.ts", "**/*.tsx", ".react-router/types/**/*"],
33
"compilerOptions": {
44
"lib": ["DOM", "DOM.Iterable", "ES2022"],
5-
"types": ["vite/client"],
5+
"types": ["@cloudflare/workers-types", "vite/client"],
66
"verbatimModuleSyntax": true,
77
"esModuleInterop": true,
88
"jsx": "react-jsx",

integration/helpers/vite-plugin-cloudflare-template/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"serialize-javascript": "^6.0.1"
1919
},
2020
"devDependencies": {
21-
"@cloudflare/vite-plugin": "^0.1.12",
21+
"@cloudflare/vite-plugin": "^0.1.13",
2222
"@react-router/dev": "workspace:*",
2323
"@react-router/fs-routes": "workspace:*",
2424
"@types/node": "^20.0.0",
@@ -28,7 +28,7 @@
2828
"typescript": "^5.1.6",
2929
"vite": "^6.1.0",
3030
"vite-tsconfig-paths": "^4.2.1",
31-
"wrangler": "^4.1.0"
31+
"wrangler": "^4.2.0"
3232
},
3333
"engines": {
3434
"node": ">=20.0.0"

integration/vite-cloudflare-test.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,34 @@ function getFiles({
2525
}
2626
`,
2727
"load-context.ts": `
28-
import { type AppLoadContext } from "@react-router/cloudflare";
29-
import { type PlatformProxy } from "wrangler";
30-
28+
import type { ExecutionContext } from "@cloudflare/workers-types";
29+
import type { AppLoadContext } from "react-router";
30+
3131
type Env = {
3232
MY_KV: KVNamespace;
3333
}
34-
type Cloudflare = Omit<PlatformProxy<Env>, 'dispose'>;
35-
36-
declare module "@react-router/cloudflare" {
37-
interface AppLoadContext {
38-
cloudflare: Cloudflare;
39-
env2: Cloudflare["env"];
34+
35+
declare global {
36+
interface CloudflareEnvironment extends Env {}
37+
}
38+
39+
declare module "react-router" {
40+
export interface AppLoadContext {
41+
cloudflare: {
42+
env: CloudflareEnvironment;
43+
ctx: Omit<ExecutionContext, "props">;
44+
};
45+
env2: CloudflareEnvironment;
4046
extra: string;
4147
}
4248
}
43-
44-
type GetLoadContext = (args: {
49+
50+
type GetLoadContextArgs = {
4551
request: Request;
46-
context: { cloudflare: Cloudflare };
47-
}) => AppLoadContext;
48-
49-
export const getLoadContext: GetLoadContext = ({ context }) => {
52+
context: Pick<AppLoadContext, "cloudflare">;
53+
};
54+
55+
export const getLoadContext = ({ context }: GetLoadContextArgs) => {
5056
return {
5157
...context,
5258
env2: context.cloudflare.env,
@@ -67,6 +73,7 @@ function getFiles({
6773
});
6874
`,
6975
"wrangler.toml": `
76+
compatibility_date = "2025-03-17"
7077
kv_namespaces = [
7178
{ id = "abc123", binding="MY_KV" }
7279
]

packages/react-router-dev/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@
115115
"typescript": "^5.1.6",
116116
"vite": "^6.1.0",
117117
"wireit": "0.14.9",
118-
"wrangler": "^4.1.0"
118+
"wrangler": "^4.2.0"
119119
},
120120
"peerDependencies": {
121121
"@react-router/serve": "workspace:^",
122122
"react-router": "workspace:^",
123123
"typescript": "^5.1.0",
124124
"vite": "^5.1.0 || ^6.0.0",
125-
"wrangler": "^3.28.2 || ^4.1.0"
125+
"wrangler": "^3.28.2 || ^4.2.0"
126126
},
127127
"peerDependenciesMeta": {
128128
"@react-router/serve": {

playground/vite-plugin-cloudflare/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"serialize-javascript": "^6.0.1"
1919
},
2020
"devDependencies": {
21-
"@cloudflare/vite-plugin": "^0.1.12",
21+
"@cloudflare/vite-plugin": "^0.1.13",
2222
"@react-router/dev": "workspace:*",
2323
"@react-router/fs-routes": "workspace:*",
2424
"@types/node": "^20.0.0",
@@ -28,7 +28,7 @@
2828
"typescript": "^5.1.6",
2929
"vite": "^6.1.0",
3030
"vite-tsconfig-paths": "^4.2.1",
31-
"wrangler": "^4.1.0"
31+
"wrangler": "^4.2.0"
3232
},
3333
"engines": {
3434
"node": ">=20.0.0"

pnpm-lock.yaml

Lines changed: 28 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)